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 |
richcol
Starting Member
5 Posts |
Posted - 2007-03-21 : 13:08:49
|
Hi All,I am having a problem trying to add a sequence of numbers to my test table and it is a bit confusing. Could anyone point me in the right direction.I have the folowingTestTablePK Clm Row1 123 02 123 03 123 04 234 05 234 06 345 0what i am trying to do is apply row numbers based on the clm column so it looks like the following:PK Clm Row1 123 12 123 23 123 34 234 15 234 26 345 1Hope this makes sense. |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2007-03-21 : 13:23:19
|
update tblset row = (select count(*) from tbl t2 where t2.Clm = t.Clm and t2.Pk <= t.Pk)from tbl t==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
richcol
Starting Member
5 Posts |
Posted - 2007-03-22 : 09:27:46
|
That's great exactly what I was looking for, many thanks. |
 |
|
|
|
|