How to Enable/Disable the Identity column?

To insert the values manually in to the identity column you have to enable by setting IDENTITY_INSERT to ON. To stop inserting the manual values into identity column you have to disable by setting IDENTITY_INSERT to OFF. Here is the script:

SET IDENTITY_INSERT <Table Name> ON; — This will enable the Identity column inserting values
<Insert Query with identity column values>
SET IDENTITY_INSERT <Table Name> OFF; — This will disable the Identity column inserting values

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

%d bloggers like this: