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 |
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2008-08-04 : 21:21:25
|
I've this in SQL Server 2000Select AccNo,CstNmefrom v_cstThen the result as follow,AccNo | CstNme-----------------002 | Gwoh Burne Loh003 | Tesk Ji005 | UJIK......How to adjust my query to add i more column as number so te result as followNo. | AccNo | CstNme-------------------------1 | 002 | Gwoh Burne Loh2 | 003 | Tesk Ji3 | 005 | UJIK4 | ...... |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-08-04 : 22:50:08
|
No real good way to do that in sql 2000. Here are 3 possibilities:1) upgrade to 2005 and use the rownumber() functionor2) create a temp table with an identity column, use your query to insert into the temp table, then SELECT from your temp table.or3) use a correlated subquery:select AccNo, CstNme, (select count(*) from v_cst where AccNo <= c.AccNo) as [No.] from v_cst cBe One with the OptimizerTG |
 |
|
Delinda
Constraint Violating Yak Guru
315 Posts |
Posted - 2008-08-04 : 23:31:47
|
thanks a lot ... it give me a great idea. |
 |
|
|
|
|