Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Generate auto row number for a table

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)