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
 Transact-SQL (2000)
 Physical row number?

Author  Topic 

Ali Chadorbaf
Starting Member

44 Posts

Posted - 2007-03-26 : 16:09:26
Hi,
I am wondering if there is a function available to tell us the physical row number in a table.

e.g.: let's say we have a table name emp with one column name firstname
I need to get the physical row no. for each row retrieved.

SELECT rowno , lastname from emp

rowno firstname
----- --------
0 Chirs
1 Jon
2 Mary
...
...
Thanks

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-03-26 : 17:07:24
there is no such thing in sql server.

you posted in a 2000 forum, but just in case you are on 2005 these new functions might help:

ROW_NUMBER(), RANK(), DENSE_RANK()


www.elsasoft.org
Go to Top of Page

Ali Chadorbaf
Starting Member

44 Posts

Posted - 2007-03-26 : 17:25:22
Thanks
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-02 : 03:26:08
If you want to show data in front end application, you can easily do numbering there

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-04-02 : 03:51:10
In SQL SERVER 2000 there is query which can achieve this but its has performance issues..


SELECT (SELECT COUNT(i.au_id)
FROM pubs..authors i
WHERE i.au_id >= o.au_id ) AS RowID,
au_fname + ' ' + au_lname AS 'Author name'
FROM pubs..authors o
ORDER BY RowID


Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2007-04-02 : 23:12:07
SELECT IDENTITY(INT,0,1) AS RowNum,
FirstName
INTO #MyHead
FROM Emp

SELECT *
FROM #MyHead
ORDER BY RowNum


--Jeff Moden
Go to Top of Page
   

- Advertisement -