首页 > 数据库技术 > 详细

sql语句影响的行数

时间:2015-07-10 12:44:27      阅读:152      评论:0      收藏:0      [点我收藏+]

全局变量@@RowCount 和函数RowCount_Big()用于返回上一条语句影响的行数。如果行数大于 20 亿,则需要使用ROWCOUNT_BIG()。

 

1,ROWCOUNT_BIG():

Following a SELECT statement, this function returns the number of rows returned by the SELECT statement.            

Following an INSERT, UPDATE, or DELETE statement, this function returns the number of rows affected by the data modification statement.            

Following statements that do not return rows, such as an IF statement, this function returns 0.

 

2, set RowCount @Num

设置sql语句影响的行数,ROWCOUNT的设置是和Session有关的。一个Session将使用最近一次设置的ROWCOUNT,直到Session结束或修改了ROWCOUNT。

SET ROWCOUNT 0

取消ROWCOUNT限制。

 

3, sample codes

SET ROWCOUNT 0
-- return 10 records
select * from dbo.test

--return value is 10
select @@ROWCOUNT

--return value is 1
select ROWCOUNT_BIG()

--alternate solution
declare @n int
set @n=10

 

sql语句影响的行数

原文:http://www.cnblogs.com/ljhdo/p/4634011.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!