码迷,mamicode.com
首页 > 数据库 > 详细

sql语句影响的行数

时间:2015-07-10 12:45:58      阅读:159      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!