Gunakan beberapa klausa ROW_NUMBER per kolom dan pilih salah satu yang relevan:
....
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
....
ATAU menggunakan ekspresi KASUS. Catatan:semua tipe data harus kompatibel
ROW_NUMBER() OVER (ORDER BY CASE @sort
WHEN 1 THEN [Column1]
WHEN 1 THEN [Column2]
WHEN 1 THEN [Column3]
...
END
ATAU Jika Anda benar-benar menginginkan nomor baris arbitrer, lakukan ini:
ROW_NUMBER() OVER (ORDER BY (SELECT 1)) as rn