Advertisement
DataCCIW

Alpha Sort Group Types

Oct 12th, 2022
1,646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.33 KB | None | 0 0
  1. BEGIN TRANSACTION AlphaSortGroupTypeOrder
  2.  
  3. UPDATE dbo.GroupType
  4. SET [Order] = Alpha.AlphaOrder
  5. FROM dbo.GroupType GT
  6. JOIN (
  7.     SELECT
  8.     [Id],
  9.     ROW_NUMBER() OVER(ORDER BY GT.[name] ASC) AS AlphaOrder,
  10.     [Name]
  11.     FROM GroupType GT
  12.     ) Alpha ON Alpha.[Id] = GT.[Id]
  13.  
  14. COMMIT TRANSACTION AlphaSortGroupTypeOrder
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement