Wednesday, July 8, 2009

Create a row number or Serial no

In Ms-Sql 2005 and Oracle we have a built in function to generate row number or Serial no, But in

Ms-sql 2000 we have to generate serial no as follows!


CREATE TABLE Sample (
Number int
)


Insert Into sample

select 1 union
select 2 union
select 3 union
select 4 union
select 5 union
select 6 union
select 7 union
select 8 union
select 9 union
select 10


Select (select count(*) from Sample where number<=T.number) as Sno ,number
from Sample as T

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.