存储过程中将@@ ROWCOUNT设置为SET NOCOUNT ON [英] @@ROWCOUNT with SET NOCOUNT ON in Stored Procedure
问题描述
大家好!
刚才,我已经阅读了此文章 [ ^ ],并不确定如何使用@@ROWCOUNT
来获取受影响的保持NOCOUNT ON
的行数.
我已经在ASP.Net(C#)中对此进行了标记,因为我将其用作前端,并且无论是否可以执行此操作都需要一些指导.
我想知道受存储过程影响的行数,并据此执行代码.因此,即使保持NOCOUNT ON
,是否有任何方法可以知道受存储过程影响的行数?
如果是,那是哪一个?
请帮助..
Hello everyone!
Just now, I have read this Article[^] and have a doubt how to use @@ROWCOUNT
to get affected number of rows keeping NOCOUNT ON
.
I have tagged this in ASP.Net(C#) as I am using it as the front end and need some guidance whether I can do this or not.
I want to know the number of rows affected by the stored procedures and accordingly execute the codes. So, is there any way to know the number of rows affected by a stored procedure even after keeping NOCOUNT ON
?
If yes, then which one?
Please help..
推荐答案
本文明确指出,
The article clearly states,
如果仍然需要获取正在执行的T-SQL语句影响的行数,您仍然可以使用@@ ROWCOUNT选项.通过在此函数上发出SET NOCOUNT,该函数(@@ ROWCOUNT)仍然有效,并且仍可以在存储过程中使用,以标识该语句影响了多少行.
If you still need to get the number of rows affected by the T-SQL statement that is executing you can still use the @@ROWCOUNT option. By issuing a SET NOCOUNT ON this function (@@ROWCOUNT) still works and can still be used in your stored procedures to identify how many rows were affected by the statement.
返回 ^ ]值,并在前端使用它.
Return the ROWCOUNT[^] value from the stored procedure and use it in the front end.
对Rajeev发表评论后:
阅读此页,您将找到答案:
http://msdn.microsoft.com/en-us/library/59x02y99%28v = vs.110%29.aspx [ ^ ]
希望对您有所帮助.
After your comments for Rajeev :
Read this page and you will find your answer :
http://msdn.microsoft.com/en-us/library/59x02y99%28v=vs.110%29.aspx[^]
Hope it helps.
这篇关于存储过程中将@@ ROWCOUNT设置为SET NOCOUNT ON的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!