SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Recordset Numbering in SQL Server queries
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 11/29/2001 :  11:05:44  Show Profile  Visit mantis's Homepage  Reply with Quote

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 - 11/29/2001 :  11:15:08  Show Profile  Send sica an ICQ Message  Reply with Quote
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 - 11/29/2001 :  17:23:05  Show Profile  Visit Merkin's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000