How can I alter a table in SQL Server Compact Edition (SQL CE)?
I have an existing table, and I need to add an IDENTITY
column.
The basic syntax of an ALTER TABLE command to add a New Column in an existing table is as follows. ALTER TABLE table_name ADD column_name datatype; The basic syntax of an ALTER TABLE command to DROP COLUMN in an existing table is as follows.
The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table.
If you use ALTER TABLE statement, it will automatically add the new column to the end of the table. The ALTER privilege is required to perform this: ALTER TABLE table_name ADD col_name data_type NULL | NOT NULL; It will not drop any existing data.
You add a column in the same way you would add it in other versions of SQL Server:
This adds a primary key identity column called IdColumnName
to the table tableName
:
ALTER TABLE tableName
ADD COLUMN IdColumnName INTEGER IDENTITY (1,1) PRIMARY KEY
See the ALTER TABLE
syntax for SQL Server compact edition.
Hope these examples help some one
ALTER TABLE [sales_order] ADD COLUMN [price] MONEY NULL;
ALTER TABLE [order_details] ADD COLUMN [price] MONEY NULL;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With