列ごとに複数の ROW_NUMBER 句を使用し、関連する句を選択してください:
....
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
....
または CASE 式を使用します。注:すべてのデータ型は互換性がなければなりません
ROW_NUMBER() OVER (ORDER BY CASE @sort
WHEN 1 THEN [Column1]
WHEN 1 THEN [Column2]
WHEN 1 THEN [Column3]
...
END
または 本当に任意の行番号が必要な場合は、次のようにします:
ROW_NUMBER() OVER (ORDER BY (SELECT 1)) as rn