Quantcast
Viewing all articles
Browse latest Browse all 35

Answer by Eric for How to select the nth row in a SQL database table?

For SQL Server, a generic way to go by row number is as such:

SET ROWCOUNT @row --@row = the row number you wish to work on.

For Example:

set rowcount 20   --sets row to 20th rowselect meat, cheese from dbo.sandwich --select columns from table at 20th rowset rowcount 0   --sets rowcount back to all rows

This will return the 20th row's information. Be sure to put in the rowcount 0 afterward.


Viewing all articles
Browse latest Browse all 35

Trending Articles