开发者

How to edit column name in Visual Studio's SQL Compact?

开发者 https://www.devze.com 2023-02-23 14:41 出处:网络
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 th

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?

How to edit column name in Visual Studio's SQL Compact?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号