Skip to content

Instantly share code, notes, and snippets.

@htuomola
Created April 24, 2012 08:18
Show Gist options
  • Save htuomola/2477807 to your computer and use it in GitHub Desktop.
Save htuomola/2477807 to your computer and use it in GitHub Desktop.
T-SQL update table with row numbers
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