2/9/2016 8:36:24 PM

Use ROW_NUMBER in a SQL query to add an incrementing value on each row return from a query. Once use for this would be to paginate the results.

--order by last name SELECT Users.FirstName ,Users.LastName ,ROW_NUMBER() OVER (ORDER BY Users.LastName) AS RowId FROM Users --order by last name DESC SELECT Users.FirstName ,Users.LastName ,ROW_NUMBER() OVER (ORDER BY Users.LastName DESC) AS RowId FROM Users