Editing Multiple Rows By Their Order Index
Q: How would I go about using / applying the row number of each row in a query to a certain column in the entire query? I've added a screenshot to try and make things more obvious:
Solution 1:
Try this :
;WITH TEST AS
(
SELECT *,
ROW_NUMBER() OVER (ORDER BY id DESC) AS RowNo
FROM [UserTable]
)
UPDATE TEST
SET myindex = RowNo
Post a Comment for "Editing Multiple Rows By Their Order Index"