Tuesday, 21 April 2020

SET ROWCOUNT in SQL Server


The SQL ROWCOUNT is one of the Set Function, which causes the SQL server to stop the query processing after the specified numbers returned.

Syntax

SET ROWCOUNT number (to stop the query)
   


Basically, if we want to get the top n records from the script in this case either we write top clause or we can set this.
For the above, we need to write the below query to get the top 2 records from the table.
   


Keep in mind when we are setting SET ROWCOUNT, it works on the current session window only if we will open other window script works as usual.

No comments:

Post a Comment

If you have any doubt, please let me know.

Popular Posts