@@ROWCOUNT
返回受上一语句影响的行数。语法
@@ROWCOUNT返回类型
integer注释
任何不返回行的语句将这一变量设置为 0 ,如 IF 语句。示例
下面的示例执行 UPDATE 语句并用 @@ROWCOUNT 来检测是否有发生更改的行。UPDATE authors SET au_lname = 'Jones'
WHERE au_id = '999-888-7777'
IF @@ROWCOUNT = 0
print 'Warning: No rows were updated'
返回受上一语句影响的行数。语法
@@ROWCOUNT返回类型
integer注释
任何不返回行的语句将这一变量设置为 0 ,如 IF 语句。示例
下面的示例执行 UPDATE 语句并用 @@ROWCOUNT 来检测是否有发生更改的行。UPDATE authors SET au_lname = 'Jones'
WHERE au_id = '999-888-7777'
IF @@ROWCOUNT = 0
print 'Warning: No rows were updated'
select Rank from Customer where CusomerType= 'VIP'
能查到几条@@rowcount就为几!
declare @id int
select @id = id from sysobjects
print @@rowcount
结果为:
833
set nocount off
select @RetValue=id from sysobjects
print @@rowcount--结果:59
select Rank from Customer where CusomerType= 'VIP'
如果有,select @@ROWCOUNT 返回不是0
楼主你在认真看看.
切记::::处理语句和取得@@ROWCOUNT的语句中间不能有其他语句
否则@@ROWCOUNT返回的值就不对了
-----------------------------------
declare @RetValue float
set nocount off
select @RetValue=Rank from Customer where CusomerType= 'VIP'print @RetValue
print @@rowcount
-----------------------------------实际上我
用ADO.NET的command对象执行ExecuteNonQuery,调用了一个存储过程,但是ExecuteNonQuery的返回值为-1;存储过程是这样的
create procedure GetRank
@RetValue float output
as
set nocount off
select @RetValue=Rank from Customer where CusomerType= 'VIP'
go不知哪里出了问题 ?