Microsoft, SQL Server, Technical

Updating Identity Columns in SQL Server

Identity columns are kind of a helpful feature. But there might be times when you would want to change the value of an identity column.Guess what, SQL server does not allow it. I have not come across a way by which you can update the identity column but there sure is a way to insert one.

SET Identity_Insert <TableName> ON

Now you will be able to insert a value into the identity column. Once done just revert the above statement to what follows to avoid unnecessary inserts:

SET Identity_Insert <TableName> OFF

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s