Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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?

enter image description here

like image 802
KMC Avatar asked Apr 08 '11 06:04

KMC


People also ask

How do you change the name of a column in SQL query?

To change a column name, enter the following statement in your MySQL shell: ALTER TABLE table_name RENAME COLUMN old_column_name TO new_column_name; Replace table_name , old_column_name , and new_column_name with your table and column names.

How do I change the column name in an Azure SQL Database?

Using SQL Server Management StudioIn Object Explorer, right-click the table in which you want to rename columns and choose Rename. Type a new column name.

How do you change the name of a column in Toad?

In SSMS right click the Table and select Design. Change the name and click save. Done!


1 Answers

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
like image 71
Edwin de Koning Avatar answered Sep 20 '22 16:09

Edwin de Koning