Click here to Skip to main content
15,886,578 members
Articles / Web Development / ASP.NET
Alternative
Tip/Trick

Generate auto row number for a table

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
28 Sep 2011CPOL 5.8K  
SELECT ROW_NUMBER() OVER(ORDER BY [col_1]) as RowNumber,COUNT([col_1]) OVER () AS RecordCount,* FROM TableName
SQL
SELECT ROW_NUMBER() OVER(ORDER BY [col_1]) as RowNumber,
COUNT([col_1]) OVER () AS RecordCount,* FROM TableName

License

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


Written By
Technical Lead
India India
Project Lead
MCTS - .NET Framework 4.0, Web Applications

Blog : http://thakkermukund.wordpress.com
Twitter@thakkermukund

Don't code today, what you can't debug tomorrow!
Everything makes sense in someone's mind

Comments and Discussions

 
-- There are no messages in this forum --