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 |
cenzor
Starting Member
1 Post |
Posted - 2012-06-17 : 14:05:20
|
Hello All,I would like to ask how to autoincrement integer value in a column based on the value in other column. I.e. if the value changes the incrementation should start again.E.g. I have a table with column A and B. Column B is blankAnd A has the following values:A Bx xxyyzzzz And I would like to update the column in the following way:A Bx 10x 20x 30y 10y 20z 10z 20z 30z 40Thank you!Jan |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-06-17 : 16:49:37
|
[code]UPDATE tB = Seq * 10FROM (SELECT ROW_NUMBER() OVER (PARTITION BY A ORDER BY (SELECT 1)) AS SeqFROM Table)t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|