Dec
25
Selecting a specific number of rows in TSQL
Filed Under (SQL) by manatarms on 25-12-2007
Tagged Under : TSQL
The other day I had the need to select an exact number of rows in a TSQL stored procedure. The circumstances constrained me in multiple ways and I just so happened to come across this little gem of a trick for selecting a set number of rows without using TOP.
All one must do is use the following assigment:
1 | SET @@ROWCOUNT = # of Rows To Select |
Then perform the select statement and your in business!