SQL Server 2005 provides a new function called Row_Number() which helps to generate row numbers in the query.
The syntax is
ROW_NUMBER() OVER (ORDER BY your_primary_column_name ASC) AS ROWID, * FROM your_table_name
Sample Query for a Customer Table is
SELECT ROW_NUMBER() OVER (ORDER BY CusCode ASC) AS ROWID, * FROM Customers Where DeptNo='HR'
Happy Queries!!
The syntax is
ROW_NUMBER() OVER (ORDER BY your_primary_column_name ASC) AS ROWID, * FROM your_table_name
Sample Query for a Customer Table is
SELECT ROW_NUMBER() OVER (ORDER BY CusCode ASC) AS ROWID, * FROM Customers Where DeptNo='HR'
Happy Queries!!
No comments :
Post a Comment