Advertisement
DataCCIW

Alpha Sort Defined Values

Jul 28th, 2022 (edited)
1,629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.48 KB | None | 0 0
  1. DECLARE @DefinedValueId INT = --Update this value before running statement below
  2.  
  3. BEGIN TRANSACTION AlphaSortDefinedValue
  4. Update DefinedValue
  5. SET [Order] = Alpha.AlphaOrder
  6. FROM DefinedValue DV
  7. JOIN (
  8. SELECT DV.Id, DV.[Value], DV.[Order], RANK() OVER (
  9.             PARTITION BY DefinedTypeId ORDER BY DV.[Value] ASC
  10.             ) AS AlphaOrder  from DefinedValue DV
  11. where DV.DefinedTypeId = @DefinedValueId
  12.  ) Alpha ON Alpha.[Id] = DV.[Id]
  13. COMMIT TRANSACTION AlphaSortDefinedValue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement