How to change column name in Visual Studio SQL Compact?

I am using WPF C # Visual Studio and SQL Compact 3.5. In the server explorer, I right-click and select "Edit Table Schema", I can change the data type, length, etc., but I can not click on the column name to change the column name. How to change column name in Server Explorer?

enter image description here

+5
source share
2 answers

Unfortunately, this is not possible in CE SQL Server. You will need to create a new column and then delete the old one. If you have data in a column, you need to transfer this to your new column. If you want to do this using the sql statement, try something like this:

ALTER TABLE myTable ADD newColumn newType

UPDATE myTable SET newColumn = oldColumn

ALTER TABLE myTable DROP COLUMN oldColumn
+6

All Articles