In Sql Server 2005 and above version you can generate serial number as:
select row_number() over(order by empid) as serial_Number, empid,empname from emp
In Sql server 2000, you can generate serial number as:
select (select sum(1) from emp a where a.empid<=obj.empid) as serial_number,* from emp obj
No comments:
Post a Comment