T-SQL update an increasing value
I have a table with many columns, one column is called "aID" and currently has no value. I want to add an increasing value here, from 1 to the amount of rows in table.
UPDATE [xx].[dbo].[UserValues] SET aID = ?? Where aID is null
How can i do this?
UPDATE t SET t.aID = t.Rn FROM (SELECT aID, ROW_NUMBER() OVER(ORDER BY aID) AS Rn FROM [xx].[dbo].[UserValues] WHERE aID is null) t