June 16, 2011 at 4:38 am
Hi,
I have a table which has more than 400.000 rows.
I need that one of it's columns named ID become identity.
The column has integer values and i want to add the identity property to the column (1,1).
How can i do this by t-sql?
Thank you
June 16, 2011 at 4:45 am
1. create a new table with the columns setup correctly, you can use your current table as a template.
2. copy the data across (select into ) from old table to new.. the id will update then
June 16, 2011 at 5:18 am
Maybe in my case it is not necessary.
This is the problem:
I have created a table named TempImport which imports data using bulk insert.
This TempImport is an empty table and every time before i load it with new data i drop the table and recreate a new one empty.
It's only a temporary table that i rename (to become a normal table) after it is all loaded
Maybe if i create the temptable already with the identity property in the comun (id) and before i do the insert by bulk insert, if i specify the set identity_insert = on and after the the bulk of the data put the set identity_insert = off my problem is solved.
What do you think?
June 16, 2011 at 5:25 am
sounds spot on.
June 16, 2011 at 5:41 am
didn't undestood your answer 🙂
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply