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?

Answers


Maybe query:

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

Need Your Help

Can i call a function via DataTrigger (XAML)?

c# wpf events command datatrigger

I have a function in .xaml.cs which i wanted to call:

form submit doesn't callback

extjs extjs4 extjs4.2

I have a form with standard submit.