Saturday, February 25, 2012

Add Identity Property to existing table

How can I add an Identity property using t-sql when the
table has already been created and the column already
exist? The column name is InvoiceItemID.
TIA,
Vic
You can't. Nor can Enterprise Manager so it creates a new table, copy over the data etc etc etc. I
suggest you do the operation in EM, and press the "save change script" button to see what SQL code
EM does for this operation.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Vic" <vduran@.specpro-inc.com> wrote in message news:0e2701c4f27f$30055240$a501280a@.phx.gbl...
> How can I add an Identity property using t-sql when the
> table has already been created and the column already
> exist? The column name is InvoiceItemID.
> TIA,
> Vic
|||> How can I add an Identity property using t-sql when the
> table has already been created and the column already
> exist? The column name is InvoiceItemID.
You can't add Identity property to an existing column. Yo can do it through
EM, but it will actually create a new table, copy all of the rows, drop the
old table and rename the new table to the old name in a single big
transaction.
Dejan Sarka, SQL Server MVP
Associate Mentor
www.SolidQualityLearning.com

No comments:

Post a Comment