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)
 queries - counting rows in a select list

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-06-28 : 09:49:31
Yossi writes "Is there a way to retrive a special field for every row in the select list
that will indicate the row number (0,1,2,3...) in the select list
without defining an identifier (identity_seed,identity_increment)
thanks"

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2002-06-28 : 11:09:29
quote:

Yossi writes "Is there a way to retrive a special field for every row in the select list
that will indicate the row number (0,1,2,3...) in the select list
without defining an identifier (identity_seed,identity_increment)
thanks"



The short answer is no. SQL is a set-based language modeled on relational algebra, and in that context there is no concept of "row number". If you want to select a row for processing, generally speaking, you must identify it purely by its column values and nothing else.

Jonathan Boott, MCDBA
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-06-28 : 11:55:33
the "long" answer is that this issue has been discussed many a time here....


search for "ranking"....there's even an article (or two) on it...."ranking" in this case means that you 'care about the order' the data is returned to you.....if you don't and all you want is a
select * from table1 (or equivalent)
with the rows numbered sequentially....then the technique mentioned may not suit you.....



Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2002-06-28 : 12:22:25
The easy answer is to look at this article:

http://support.microsoft.com/default.aspx?scid=kb;en-us;Q186133&SD=MSKB&

-Chad

Go to Top of Page
   

- Advertisement -