Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 altering a column to identity column

Author  Topic 

spock
Starting Member

35 Posts

Posted - 2002-08-01 : 07:39:28
Hi

I have a table like

create table #a (empid int,names varchar(30))

i add some records into this table.

I want to now change the empid column to a identity column and preserver the existing empid's . how do i do it ?

Thanks
kaushik

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2002-08-01 : 11:32:43
just set it to identity in EM table designer..

Peace

Rick

Go to Top of Page

spock
Starting Member

35 Posts

Posted - 2002-08-01 : 23:59:01
thanks Rick

but i was wondering how would you write a query for that.

Thanks
Kaushik

Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-08-02 : 08:13:48
You'd have to:

-create a new table with the same structure but with an identity column
-set identity_insert on and then insert the data into the new table
-drop the old table
-rename the new table to the old name

This is more or less what EM does behind the scenes.

Go to Top of Page
   

- Advertisement -