Wednesday, 6 February 2013

Adding serial number for rows in SQL Server

Adding serial number based on number of rows displaying.

You need to add following to your query or Column Name

Syntax :


Row_Number() Over (Order By a.emp_mast_id) As emp_mast_id

Example  :


select Row_Number() Over (Order By a.emp_mast_id) As emp_mast_id,
a.emp_name,
a.address
from Emp_mast a


ID   Name   Address
1     Nihar    India
2     sam       UK
3     John      USA


No comments:

Post a Comment