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 |
ugh3012
Yak Posting Veteran
62 Posts |
Posted - 2013-11-14 : 14:07:02
|
I have a table with no sequence column. I created a new column, but I need a way to add sequence number. This is not going to be a Primary key or indexed. I assume I will use update, but how do I do this? ExampleBeforeName | SeqPaul | NULLTom | NULLGrant | NULLAfterName | SeqPaul | 1Tom | 2Grant | 3 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-11-14 : 14:28:25
|
[code]UPDATE tSET Seq = RnFROM (SELECT Seq,ROW_NUMBER() OVER (ORDER BY (SELECT 1)) AS RnFROM Table)t[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|