开发者

insert issues in an auto increment column

开发者 https://www.devze.com 2023-03-05 06:19 出处:网络
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 r

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

精彩评论

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