以下SQL语句的差异? [英] Differnce in following SQL Statement ?

查看:75
本文介绍了以下SQL语句的差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

插入声明后: -

(1)SELECT SCOPE_IDENTITY()FROM< tn>



(2)SELECT SCOPE_IDENTITY()

After Insert statement :-
(1)SELECT SCOPE_IDENTITY() FROM <t.n.>
and
(2)SELECT SCOPE_IDENTITY()

推荐答案

如果指定一个表,则会假定它将返回当前作用域中插入该表的最后一个标识。您是否考虑编写SQL来测试并查看它的作用?
If you specify a table, one would assume that it would return the last identity inserted in to that table, in the current scope. Did you consider writing SQL to test and see what it does ?


SELECT SCOPE_IDENTITY()FROM Table将根据您使用的表多次返回作用域标识的值。如果表有50行,最后插入的值是85,它将返回50行,每行值为85.

此外,标识值可能不是来自同一个表。





SELECT SCOPE_IDENTITY()将返回最后插入的标识值。
SELECT SCOPE_IDENTITY() FROM Table will return value of scope identity multiple time based on which table you use . If table has 50 rows and last inserted value is 85 it will return 50 rows with value 85 each.
Also the identity value may not be from the same table.


SELECT SCOPE_IDENTITY() will return last inserted identity value.


这篇关于以下SQL语句的差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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