Add Identity Key behaviour to existing primary key column.
-
Hi guys, Back with another question :) Create Table TestTable ( TestTableId Int Not Null, TestTableName Varchar(100), Primary Key (TestTableId) ); Now i want to alter the TestTableId column and change it to an Identity Key. I heard that theres no direct syntax for this as such. But is this possible through SQL Server 2008?
The name is Sandeep
-
Hi guys, Back with another question :) Create Table TestTable ( TestTableId Int Not Null, TestTableName Varchar(100), Primary Key (TestTableId) ); Now i want to alter the TestTableId column and change it to an Identity Key. I heard that theres no direct syntax for this as such. But is this possible through SQL Server 2008?
The name is Sandeep
As far as I know it's not possible in SQL Server 2008 either. Why not use temp table in the process, like: - create temp table as you want the table to be - set IDENTITY_INSERT ON - copy the data to temp table using INSERT INTO ... SELECT ... - set IDENTITY_INSERT OFF - drop the original table - rename the temp table to orginal table using sp_rename
The need to optimize rises from a bad design. My articles[^]