@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT [sql server 2005] [英] @@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT [sql server 2005]
问题描述
我应该使用哪个来获取 sql server 2005 中最后插入的记录 ID?
Which should i use to get last inserted record id in sql server 2005?
我搜索了stackoverflow,我找到了这个,
I searched stackoverflow and i found this,
最佳答案评论:
sql server 2005 中存在 SCOPE_IDENTITY() 的已知错误,不确定 2008 年,如果需要,OUTPUT 子句可以返回一组 ID...
there are known bugs with SCOPE_IDENTITY() in sql server 2005, not sure about 2008, the OUTPUT clause can return a set of IDs if necessary...
Select SCOPE_IDENTITY() as Id from Table
我正在使用 sql server 2005...任何建议
I am uisng sql server 2005... Any suggestion
推荐答案
我不完全确定这些知道错误"是什么;在 SCOPE_IDENTITY() 应该是.我目前唯一知道的是:你应该对并行性感到紧张的六个原因 作为第一点提到.
I'm not entirely sure what these "knows bugs" in SCOPE_IDENTITY() should be. The only thing I'm currently aware of is here: Six reasons you should be nervous about parallelism mentioned as the very first point.
这篇关于@@IDENTITY vs SCOPE_IDENTITY() vs IDENT_CURRENT [sql server 2005]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!