Friday, March 23, 2012

How to change identity to an existing column?

Hi

can anybody tell , Is it possible to alter existing column to add IDENTITY?

Thanks in advance

Yes

It is possible to add Identity Column to a table already have some data. BUT there is no such a command to alter a column to be an IDENTITY Column. You have to go through the following steps.

1. Create a same table with the IDENTITY COLUMN. but with diffrent Name
2. Move all data to the New Table, with IDENTITY INSERT ON option
3. Drop All constraints from the OLD table
4. Drop the OLD table
5. Rename the new table as the OLD table
6. Attach all constraints to the new table ...

Hope that it will help

|||Thank u akbar

No comments:

Post a Comment