Thursday, July 21, 2011

row_number() function in sql server to get row offsets

This function started in sql server 2005 onwards.


you will get the records with each row having a row number like this:

rowno objectid
1          371178
2          371179
3          371181
4          371182

This is good when you want in between rows; lets say you want rows between 125 and 226 rows.
Though you can use between but between actually searches the data between the mentioned columns on which we are searching/filtering.

row_number() over (order by projectid) as rowno,objectid,tid,name from csforum

No comments:

Post a Comment