scope_identity()和current_identity()之间有什么区别? [英] What is the difference between scope_identity() and current_identity()?

查看:83
本文介绍了scope_identity()和current_identity()之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

scope_identity()和current_identity()有什么区别?





Scope_identity和当前_identity都相似,它们会返回表中生成的最后一个标识值。

Scope_Identity将返回当前在范围内的表中的标识值





这个问题的正确定义是什么? .....

解决方案

SCOPE_IDENTITY返回当前范围内生成的最后一个Identity值 - 当前会话中的此存储过程,触发器或函数。



IDENT_CURRENT(不是Current_identity,SQL中没有这样的东西)返回在特定表上生成的最后一个标识,而不是当前范围中的最后一个标识。 />


因此,如果您有一个SP在两个不同的表中生成两个不同的标识值,SCOPE_IDENTITY将只返回最后一个表的标识,而IDENT_CURRENT可以为任一个表返回它

What is the difference between scope_identity() and current_identity()?


Scope_identity and current _identity both are similar and it will return the last identity value generated in the table.
Scope_Identity will return the identity value in table that is currently in scope


is it correct definition for this question? .....

解决方案

SCOPE_IDENTITY returns the last Identity value generated within the current scope - this stored procedure, trigger or function within the current session.

IDENT_CURRENT (not Current_identity, there is no such thing in SQL) returns the last identity generated on a particular table, rather than the last in the current scope.

So if you have a SP that generates two different identity values in two different tables, SCOPE_IDENTITY will return only the Identity for the last table, while IDENT_CURRENT can return it for either table.


这篇关于scope_identity()和current_identity()之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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