Published:
Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.
Here's a handy sql snippet from my archives. This allows us to populate a database column with an incrementing value. I found this useful when I was forced to manually migrate a bunch a historical data from a weird proprietary system a couple of years ago.
What I find interesting about this snippet is how it simply demonstrates chaining of variable assignment as part of an update operation.
DECLARE @id INT
SET @id = 0
UPDATE sometable
SET @id = id = @id + 1
Reader Comments