How can I insert data into a column which has been defined as auto increment column using identity inse开发者_运维百科rt?please explain with an example.
If you have an "auto-increment" column - you really shouldn't be inserted specific values into that column yourself - after all, that's why it's an auto-increment column....
If you must do so after all - then you need to do:
SET IDENTITY_INSERT (your table name here) ON
INSERT INTO (your table name here) (IdentityCol, OtherCol1, .....)
VALUES( (new ID value), .......)
SET IDENTITY_INSERT (your table name here) OFF
精彩评论