Gebruik meerdere ROW_NUMBER-clausules per kolom en kies de relevante:
....
ROW_NUMBER() OVER (ORDER BY [Column1]) as rn1,
ROW_NUMBER() OVER (ORDER BY [Column2]) as rn2,
ROW_NUMBER() OVER (ORDER BY [Column3]) as rn3,
ROW_NUMBER() OVER (ORDER BY [Column4]) as rn4
....
OF gebruik een CASE-expressie. Opmerking:alle datatypes moeten compatibel zijn
ROW_NUMBER() OVER (ORDER BY CASE @sort
WHEN 1 THEN [Column1]
WHEN 1 THEN [Column2]
WHEN 1 THEN [Column3]
...
END
OF Als je echt een willekeurig rijnummer wilt, doe dan dit:
ROW_NUMBER() OVER (ORDER BY (SELECT 1)) as rn