DECLARE @id INT
SET @id = 6000
UPDATE Table
SET @id = id = @id + 1
No words wasted! Getting to the point about the work I do, the problems I deal with, and some links to posts about where I work.
Translate
Wednesday, August 18, 2021
TSQL - Add a Sequential Number Field
I needed to insert records from one table into another table and add a sequential number that started at a certain value. This was the eastiest way that I found to add the number. Just add an int field to the source table and add the values using an update. So in the following code, id was the int field that I created, and I add numbers begining with 6001.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Thank you for commenting!