开发者

insert issues in an auto increment column

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜