开发者

ABOUT SCOPE_IDENTITY

开发者 https://www.devze.com 2023-01-19 11:15 出处:网络
SELECT SCOPE_IDENTITY is always resulting id=1, what i hav开发者_如何转开发e done wrong? how to getthe currentid of the inserted element.A good article on the different methods to

SELECT SCOPE_IDENTITY is always resulting id=1, what i hav开发者_如何转开发e done wrong? how to get the currentid of the inserted element.


A good article on the different methods to retrieve the last inserted.


SCOPE_IDENTITY does indeed return the identity column of the last inserted row in the scope you are in.

It can be messed up by a few things, within the same scope. In that case IDENT_CURRENT('myTable') will be better.

If not you'll want to post more code. SCOPE_IDENTITY does work as you think, so the problem is likely elsewhere.


Are you doing it within the same trasaction? Is the identity actually being incremented in the Database?


Is the column set as Is Identity=Yes?

0

精彩评论

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