Created
April 24, 2012 08:18
-
-
Save htuomola/2477807 to your computer and use it in GitHub Desktop.
T-SQL update table with row numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WITH cte_Table AS | |
( | |
SELECT fieldToUpdate, ROW_NUMBER() OVER (ORDER BY Id) AS rownum | |
FROM table | |
) | |
UPDATE cte_Table | |
SET fieldToUpdate = rownum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment