Search This Blog

Tuesday, September 11, 2012

How to generate serial number in sql without using identity column?

In sql, there is a method Row_Number() using which you can generate sr. no.

Example:

SELECT Row_Number() Over(Order by ID) AS SrNo , colmn1, colmn2....
FROM tblTemp

Output
SrNo Colmn1 Column2 ...
1 .. .. ..
2 .. .. ..
3 .. .. ..

No comments:

Post a Comment