INSERT values into IDENTITY columns

Yesterday I had to recreate a table because it has different a column order in the DEV and in the TEST environment. Since it was too large to drag-and-drop column on the SSMS table design screen I had to use a very simple trick:

  • script the table in SSMS and recreate it with a new name
  • use the SET IDENTITY_INSERT TablaName ON before the INSERT command and OFF after the INSERT command

That's all! :D I know it's not a big deal but at first when I began looking for a solution in google I found forums that suggested a solution that wouldn't have been implemented in my case.

Why did the different column order bother me? Because we use the Synchronise Dirs command of Total Commander to compare the scripted databases and it's much better when files are identical than checking every time that only the column order differs.

Published 26 February 2009 11:01 by MartinIsti

Comments

No Comments
Powered by Community Server (Commercial Edition), by Telligent Systems