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.
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 firstnameI need to get the physical row no. for each row retrieved. SELECT rowno , lastname from emprowno firstname----- -------- 0 Chirs1 Jon2 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 |
 |
|
Ali Chadorbaf
Starting Member
44 Posts |
Posted - 2007-03-26 : 17:25:22
|
Thanks |
 |
|
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 thereMadhivananFailing to plan is Planning to fail |
 |
|
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 oORDER BY RowID Chiraghttp://chirikworld.blogspot.com/ |
 |
|
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 |
 |
|
|
|
|