Wednesday, May 23, 2012

Forcing an Identity ID into a SQL Table

If you're ever in a situation where you messed up and deleted a record, and you need to insert back in a record.. and the primary key has to be what you WANT it to be, and not what the auto-increment adds for you, here's how you do it:

 SET IDENTITY_INSERT ON
INSERT INTO ... 


 Very simple but handy little tool to know.

No comments:

Post a Comment