Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
How to display serial number as first column based on the n number of rows in SQL Query...?
Posted
Updated 7-Sep-11 22:05pm
v2

 
Share this answer
 
Comments
Suresh Suthar 8-Sep-11 4:16am    
Good link. 5!
If you are using SQL Server 2005 or more than use this

SQL
SELECT ROW_NUMBER()  OVER (ORDER BY  ColumnName1) As SrNo, ColumnName1,  ColumnName2 FROM  TableName
 
Share this answer
 
Comments
Mehdi Gholam 8-Sep-11 4:12am    
Just posted the same, 5!
Suresh Suthar 8-Sep-11 4:15am    
Yeah, I saw. Thanks.
SELECT identity(int,1,1) as [Serial#], 'Hello' AS [MyColumn] INTO #temp
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900