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
 General SQL Server Forums
 New to SQL Server Programming
 Can we convert an existing column to Identity type

Author  Topic 

arorarahul.0688
Posting Yak Master

125 Posts

Posted - 2010-03-30 : 01:42:13
Hi All,

Can you please help me on this...

Can I alter a column in an existing table, to identity column. Table doesn't contains any data till the moment.

I cant drop the column or table to redesign as the column is primary key in table and 'On delete cascade option' is not on.

Thanks,

Rahul Arora
NCCE, Panipat


######################
IMPOSSIBLE = I+M+POSSIBLE

senthil_nagore
Master Smack Fu Yak Hacker

1007 Posts

Posted - 2010-03-30 : 01:59:40
Alter the column as identity is not possible.

Rather the you have two option

1.Recreate the table with identity and drop the old one.
2.Create a new column with identity and drop the old column.

Senthil.C
------------------------------------------------------
[Microsoft][ODBC SQL Server Driver]Operation canceled

http://senthilnagore.blogspot.com/
Go to Top of Page

maevr
Posting Yak Master

169 Posts

Posted - 2010-03-30 : 02:09:48
If you have ms sql srvr mgmt studio you can do it. You just have to do it manually, not in script or command form.

1. connect to your db
2. show the table/column names in object explorer window
3. right click on column name
4. select modify in column properties tab
5. alter "identity specification"/"is identity" to YES
6. set increment/seed properties as desired

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-03-30 : 13:15:18
see

http://www.mssqltips.com/tip.asp?tip=1397

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -