Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Recordset Numbering in SQL Server queries

Author  Topic 

Starting Member

1 Post

Posted - 2001-11-29 : 11:05:44

I've to number the records in a SQL query made with SQL Server 2000. I need a field containing the number of that specific row starting from 1 and ending with the number of records retrieved.


1, Field1, Field2, Field2....., FieldN
2, Field1, Field2, Field2....., FieldN
3, Field1, Field2, Field2....., FieldN
N, Field1, Field2, Field2....., FieldN

Where the first field will contain the row number.
Can someone help me?


Even the smallest person may change the course of the future!

Posting Yak Master

143 Posts

Posted - 2001-11-29 : 11:15:08
In SQL SERVER 7.0 I would put the result of the query in a temp table with an incremental column and do a new select from the temp table.

In SQL SERVER 2000 ,maybe a function would help you...


Go to Top of Page

Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2001-11-29 : 17:23:05
I don't think a funtion would help too much, but in SQL 2000 using a table variable instead of a temp table is a little faster.

Or, this might help get the specific rows

Go to Top of Page

- Advertisement -