如何获取下一个标识而不是最后插入的标识列标识 [英] how to get next Identity not the last inserted identity of Identity column

查看:55
本文介绍了如何获取下一个标识而不是最后插入的标识列标识的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表购买和购买产品

购买主键自动增量标识栏

是否有可能获得下一个标识列的标识并锁定它所以没有任何东西可以在purchaseProduct表中插入错误

i have 2 table purchase and purchaseProduct
purchase has primary key auto increment identity column
is it possilbe to get next identity of identity column and lock it so nothing can get wrong to insert in purchaseProduct table

推荐答案

不,这不保证。您可以轻松找到下一个标识值,但在您可以使用它之前,可能会使用另一个命令。请参阅此处的类似主题 [ ^ ]。





- Amit
No, that's not guaranteed. You can easily find the next identity value, but another command might go and use it before you can make any use of it. See the detailed explanation here in a similar thread[^].


--Amit


这篇关于如何获取下一个标识而不是最后插入的标识列标识的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆