![]() ![]() (Note that the 4 steps above are prerequisites for this technique. Rename the primary key (I usually use the same name and put a 2 behind it) Rename the table in the script and add identity(1,1) to the column you need the identity onģ. Script out the table definition to a queryĢ. The easiest way I have found to add an identity to an existing column (assuming you don't have direct access through SSMS) is toġ. SSMS do this graphically, but internally it also recreate the table, load the data & drops the table. You would need to re-create table load the data again and drop the old table. Which is not possible by the ALTER statement. Here the table does not contain any IDENTITY column and wants to change the column property to IDENTITY. ![]() With this you can alter the column for thats why they call half knowledge is dangerous thing.ĭBCC CHECKIDENT only applies to Identity columns, if a table have it. I use DBCC Checkident with reseed option to reset identity columnsĭBCC CHECKIDENT ('HumanResources.Employee', RESEED, 30) You have been given bogus misinformation, which is annoying appearing in SQL-Server Help You do not need to drop the table or column. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |