Ask Your Question
1

What is the process of updating the Identity Column in SQL Server?

asked 2022-07-22 11:00:00 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-08-08 23:00:00 +0000

david gravatar image

The process of updating the Identity Column in SQL Server involves the following steps:

  1. Disable the identity column: Use the following command to turn off the identity column property on the column:

    ALTER TABLE TableName ALTER COLUMN ColumnName DROP IDENTITY

  2. Update the column values: Use the UPDATE statement to modify the values in the column.

  3. Enable the identity column: Use the following command to turn on the identity column property on the column:

    ALTER TABLE TableName ALTER COLUMN ColumnName ADD IDENTITY (NewSeedValue, IncrementValue)

    NewSeedValue: The new starting value for the identity column.

    IncrementValue: The new increment value for the identity column.

  4. Reseed the identity column: Use the following command to reset the identity value of the column:

    DBCC CHECKIDENT ('TableName', RESEED, newseedvalue)

    newseedvalue: The new starting value for the identity column.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-22 11:00:00 +0000

Seen: 8 times

Last updated: Aug 08 '21