Created
February 10, 2015 14:31
-
-
Save zommarin/1edc49ff460098d00c7c to your computer and use it in GitHub Desktop.
Number rows in SQL Server using CTE
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 T AS ( | |
SELECT | |
STEPNO, | |
Row_Number() OVER (PARTITION BY JOBNAME ORDER BY STEPNO) AS RN | |
FROM STEP | |
WHERE BR = '00' | |
) | |
UPDATE T | |
SET | |
STEPNO = RN | |
SELECT * FROM STEP WHERE BR = '00' ORDER BY JOBNAME, STEPNO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment