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 |
|
hafizsohaib
Starting Member
3 Posts |
Posted - 2003-01-17 : 12:03:25
|
| i have a table TEMP with 100 rows and 3 columns and,i want to Select all these rows with 1 extra column named Serial Number.the result set should be...S# col1 col2 col31 a a a2 b e t 3 c e a4 d s t5 e g h. . . .. . . .. . . .my problem is to add a Record Number or Serial Number with each row. |
|
|
graz
Chief SQLTeam Crack Dealer
4149 Posts |
Posted - 2003-01-17 : 12:09:16
|
| You are in luck! We wrote an article on returning a row number in a query:http://www.sqlteam.com/item.asp?ItemID=1491===============================================Creating tomorrow's legacy systems today.One crisis at a time. |
 |
|
|
hafizsohaib
Starting Member
3 Posts |
Posted - 2003-01-18 : 02:27:25
|
| Good Guys its too much help ful.is there any other without temp table |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2003-01-18 : 15:44:35
|
| Several methods posted over past few monthsnr techniqueset rowcount 1 while exists (select * from tbl where MEMBER_KEY is null update tbl set MEMBER_KEY = (select coalesce(max(MEMBER_KEY),0) + 1 from tbl) set rowcount 0 page47 techniqueupdate sset member_key = ( select count(*) from sometable where surname < s.surname )from sometable srobvolk techniqueDECLARE @seq int SELECT @seq=0 UPDATE table SET @seq = SEQUENCE_ID = @seq+1 |
 |
|
|
|
|
|