How to add sequence number column into result data?
sql-server, sql-server-2008
Solution
Using `ROW_NUMBER()` (documentation)
SELECT ROW_NUMBER() OVER (ORDER BY EmpID ASC) AS No,
EmpID, EmpName, Salary
FROM Employee
See in action
Problem
Possible Duplicate: Add row number to this T-SQL query Im using sql server 2008. When I type: select * from Employee. The result like this: ``` EmpID | EmpName | Salary ------------------------------------- DB1608 | David | 100000 JT2607 | John | 150000 AM1707 | Ann | 140000 ML1211 | Mary | 125000 ``` But I want the result like this: ``` No | EmpID | EmpName | Salary -------------------------------------------------- 1 | DB1608 | David | 100000 2 | JT2607 | John | 150000 3 | AM1707 | Ann | 140000 4 | ML1211 | Mary | 125000 ``` The column "No" is the auto increment number, and NOT the identity field in this table. How can I do this?