Row_number() Function with no specific order
Row_number() function is used to generate row number to rows based on the column which is ordered
What if you want to generate row number without ordering any column
Here is the method (Consider Suppliers table from northwind database)
1 Assign
dummy column with literal 0 and order it by that column
select row_number() over(order by order_col),companyname,address from
(
select companyname,address,0 as order_col from northwind..Suppliers
) as t
2 Assign
dummy column with literal 0 directly on the Order by clause
select row_number() over(order by (select 0)),companyname,address from northwind..Suppliers
Also refer Multipurpose Row_Number() Function