How to edit column name in Visual Studio's SQL Compact?
I use WPF C# Visual Studio and SQL Compact 3.5. On server explorer, I right click and select "Edit 开发者_C百科Table Schema", I can only change the data type, length,..etc but I cannot click into the Column Name to change the column name. How to change the column name in Server Explorer?
Sadly, this is not possible in SQL server CE. You will have to create a new column and then remove the old one. If you have any data in your column you will need to migrate this to your new column first. If you want to do it with an sql statement, try something like this:
ALTER TABLE myTable ADD newColumn newType
UPDATE myTable SET newColumn = oldColumn
ALTER TABLE myTable DROP COLUMN oldColumn
You can use sp_rename - http://erikej.blogspot.com/2007/08/hidden-gem-rename-table.html
精彩评论