ROW_NUMBER is a function built-in to SQL Server that will return a row number for each record in your result set. You can further change resulting row number to reset the row number based on some value in the result set.
PARTITION BY – If you supply this parameter, then the row number will reset based on the value changing in the columns supplied. This is kinda like using a GROUP BY.
ORDER BY – This is the specified order of the row number that you would like. If you wanted the order of the row number to increment by an employee name (alphabetically), you do that here.
select ROW_NUMBER() over (ORDER BY emp_name) AS RowNumber,Emp_ID,Emp_Name,Emp_Sal from Employee
select ROW_NUMBER() over (PARTITION BY emp_sal ORDER BY emp_name) AS RowNumber,Emp_ID,Emp_Name,Emp_Sal from Employee