Sean Pearce (6/29/2014)
Welsh Corgi (6/28/2014)
Sean Pearce (5/21/2014)
Welsh Corgi (5/20/2014)
You are right you can't set the Identity Property to true.You can set the identity property to false by simply going into design mode and set the property to false.
I just wanted to know how to do it in T-SQL.
I guess I could find out how to do so by setting up a trace.
Thank you.
SSMS will create a new table, copy the data across, delete your original table and rename the new one.
I did not see the command to change the column to an identity in you example?
There isn't one.
CREATE TABLE NewTable (ID INT IDENTITY(1, 1));
GO
SET IDENTITY_INSERT NewTable ON;
GO
INSERT INTO NewTable (ID)
SELECT * FROM OldTable;
GO
SET IDENTITY_INSERT NewTable OFF;
GO
DROP TABLE OldTable;
GO
EXEC sp_rename 'NewTable', 'OldTable';
GO
And Vice Versa
ok, thank you:-)
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/