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 |
glendcruz
Yak Posting Veteran
60 Posts |
Posted - 2010-09-09 : 21:08:03
|
Hi Everyone,I need to find out the record number in a tableEg i have a table Table xName John -- this is the first recordsonia -- the second record ----etcI just want the record numberI am running into a brick wall, can any one help pleaseThanks in advance |
|
malpashaa
Constraint Violating Yak Guru
264 Posts |
Posted - 2010-09-09 : 23:09:50
|
There is no such thing like Record Number. But if you want a sequential number of rows you can use ROW_NUMBER.SELECT ROW_NUMBER() OVER(ORDER BY Name) AS RecordNumber FROM x |
 |
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-09-10 : 12:32:13
|
It would be better to have a proper table structure, but maybe you can make use of a physical row mapping?-- 2005SELECT %%LockRes%%, *FROM MyTable-- 2008SELECT %%physloc%%, *FROM MyTable |
 |
|
glendcruz
Yak Posting Veteran
60 Posts |
Posted - 2010-09-11 : 01:44:54
|
This example written by malpashaaSELECT ROW_NUMBER() OVER(ORDER BY Name) AS RecordNumber FROM xThis exampole written by lamprey SELECT %%LockRes%%FROM MyTableThis too gives a number of characters which does not make sense.I will explain the problem once againSELECT * FROM S_EMPWHERE DEPT_ID = 31The result set will be id, Lantname, first_name,,,,,, dept-id231 Jackson john ---- 31 47 Glen Dcruz ---- 31 Now jackson could be on row number 25 on the table and Glen could be on rownumber 55 on the table. How do i get the right row number .Let me know if you have any ideasThanks once again for your help. |
 |
|
|
|
|
|
|