Global variables @ @RowCount and function rowcount_big () are used to return the number of rows affected by the previous statement. If the number of rows is greater than 2 billion, you need to use Rowcount_big ().
1,rowcount_big ():
Following a SELECT statement, this function returns the number of rows returned by the SELECT statement.
Following an inserts, UPDATE, or DELETE statement, this function returns the number of rows affected by the data Modificati On statement.
Following statements that does not return rows, such as a IF statement, this function returns 0.
2, set RowCount @Num
Set the number of rows affected by the SQL statement, and the rowcount setting is related to the session. A session will use the last set of rowcount until the session ends or the rowcount is modified.
SET ROWCOUNT 0
Cancels the rowcount limit.
3, sample Codes
SET ROWCOUNT 0--return Ten RecordsSelect * fromdbo.test--return value is tenSelect @ @ROWCOUNT--return value is 1SelectRowcount_big ()--Alternate SolutionDeclare @n intSet @n=Ten
The number of rows affected by the SQL statement