Created
July 11, 2012 20:49
-
-
Save danieljimenez/3093332 to your computer and use it in GitHub Desktop.
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 sortOrderFixer AS | |
( | |
SELECT [YourId], ROW_NUMBER() OVER(ORDER BY [NameColumn] asc) AS RowNum | |
from [YourTable] | |
where active = 'yes' | |
) | |
update [YourTable] set SortOrder = sortOrderFixer.RowNum | |
from [YourTable] t join | |
sortOrderFixer on sortOrderFixer.[YourId] = t.[YourId] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment