Please start any new threads on our new site at https://forums.sqlteam.com. 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)
 Get the row# of a recordset

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-28 : 15:18:00
Calvin writes "I have a select statement:

select c1,c2 from t where c1 = 100 order by c2
-----------------------------------------------

What I want to do is assign a row# to every row returned

select row#, c1,c2 from t where c1 = 100 order by c2
----------------------------------------------------

So the returned resultset will look like this:

1 c1,c2
2 c1 c2,
...
10 c1 c2
---------------------

Is there any way to accomplish this without using a temporary table?

Calvin"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-07-28 : 15:38:07
Yes, read this:

http://www.sqlteam.com/item.asp?ItemID=1491

At the very end is a non-temp table method.

Go to Top of Page
   

- Advertisement -