Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

get row number in select 1

Status
Not open for further replies.

hvisionexpo

Programmer
Apr 19, 2005
43
US
is it possible to get row number in a select statement?

e.g. the 5th record will have a rownumber value of 5,
row 9 will have value of 9

Thanks
 
Are you using SQL 2000 or SQL 2005. SQL 2005 has a rownumber function specifically for this purpose. If you are using SQL 2000, then you'll need to add your data to a table variable or a temp table that has an identity column and then take the data from there.

Of course, the easiest method would be to add the row number in the front end (where you display the data).

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top