Hi,
@@ROWCOUNT is a system variable which will return the no of rows affected in the DML operations.
The ROWCOUNT is one of the performance tuning mechanism. If you use the below query
what it does if you have n number of records then it has to be sorted then it will take the 5 records.
SELECT TOP 5 * FROM Employees ORDER BY Salary DESC
There is an alternative way to achieve the same result.
SET ROWCOUNT 5
SELECT * FROM Employees ORDER BY Salary DESC
SET ROWCOUNT 0
It wont list the entire record. It will get stop when the resultset reach 5 for the current single connection.
we have to set ROWCOUNT 0 for release the set count rows. Otherwise it will return the same 5 rows for that connection.
But i think there is some impact on DML operations. Yes, if you update the records then it may restrict.