Generate row ID (T-SQL)

Let's assume we have all our data in a table MyTable, with a column named MyTableID, that we want to fill with unique consecutive values.

DECLARE @Index BIGINT
SET @Index = 0

UPDATE MyTable
SET @Index = MyTableID = @Index + 1

No comments: