I have 109 tables in my database. Now I am migrating to Amazon server with identity insert and I want to remove auto increment column specification for all tables. How set auto increment column i.e. Identity specification to "no" in SQL Server 2008 for all tables?
For Example, I have
CREATE TABLE dbo.tbl_acc
(
a1 NUMERIC (18) IDENTITY NOT NULL,
a2 NUMERIC (18) NULL,
a3 VARCHAR (4000) NULL,
a4 VARCHAR (3999) NULL,
CONSTRAINT PK_tbl_acc PRIMARY KEY (a1)
)
GO
And now I would like to remove IDENTITY, not only for this but for all remaining tables.
Best Answer
There is no built-in command to remove the identity property from a column in SQL Server. You may have to create a new table, copy all the data across, and then rename the table. This can be time-consuming and awkward, especially if you have things like foreign key constraints, schema-bound functions, indexed views and so on.
That said, there is a way to avoid copying the data at least, but again this will not work in all scenarios, particularly if you have foreign keys. Example follows:
Example table and data
Meta data transfer and rename