可以在存储过程外使用SELECT IDENT_CURRENT(TableName)吗? [英] Can SELECT IDENT_CURRENT(TableName) be used outside a stored procedure?

查看:87
本文介绍了可以在存储过程外使用SELECT IDENT_CURRENT(TableName)吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SELECT IDENT_CURRENT(TableName)可以在存储过程之外使用吗?





我在msdn中看到的所有例子都是存储过程相关的。它是否仅适用于存储过程?

Can SELECT IDENT_CURRENT(TableName) be used outside a stored procedure?


All examples I saw in msdn were stored procedure related.Is it that it is meant only for stored procedures or not?

推荐答案

不,您也可以在普通编程中使用它。

我会建议反对它:它是任何会话,任何范围=这意味着它可能与你所做的任何事情有关,也可能没有,但可能完全是一个不同的用户行为。如果可以,请使用@@ IDENTITY。

MS上有一个非SP示例: http://technet.microsoft.com/en-us/library/aa933217(v = sql.80).aspx [ ^ ]
No, you can use it in "normal" programming as well.
I would advise against it though: it is "any session, any scope" = which means it may or may not relate to anything you have done, but could be a different user action entirely. Use @@IDENTITY instead if you can.
There is a non-SP example on MS here: http://technet.microsoft.com/en-us/library/aa933217(v=sql.80).aspx[^]


这篇关于可以在存储过程外使用SELECT IDENT_CURRENT(TableName)吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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