How can I add a column to an existing table?

Shiny picture Shiny · May 15, 2010 · Viewed 15k times · Source

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.

Answer

Oded picture Oded · May 15, 2010

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.