SQL SERVER – Explicitly Inserting a value into an Identity Column

When I am working with the .Net developers,there arise a situation to insert a value into the Identity column.I think most most of the developers know this answer because most people come around the situation and the solution is

SET IDENTITY_INSERT table_name ON –setting here that we are going

— to  insert a explicit value — to  the   the identity column

Note: A very interesting thing is that we can set this command to only one table at a time in  a Database. If we want to use it for another table,  we have to add SET IDENTITY_INSERT table_name OFF to the existing table where the identity insert is on.

print

Leave a Reply

Your email address will not be published. Required fields are marked *


+ four = 5