Click here to Skip to main content
15,798,825 members
Articles / Web Development / ASP.NET

Generate auto row number for a table

Rate me:
Please Sign up or sign in to vote.
4.90/5 (3 votes)
2 Oct 2011CPOL 24.5K   2   2
Generate auto row number for a table
This is a really a great experience for me because I got an opportunity to work for mid level ASP.NET web application, actually it’s remodeling of winFrom application to standard ASP.NET 3.5 web application where I worked with almost 50 tables and I found that all the tables using Guid()/ NweId() ( return 36 digit alphanumeric character) for PK and FK key mapping. I discussed with my team lead about this issue because I want the data paging to be server side and data shorting will be client side where I must be concerned about application performance, each table contains more than 10 thousand of rows. So I finally discovered that a single SQL function could resolve these issues.

Transact- SQL

SELECT ROW_NUMBER() OVER(ORDER BY [col_1]) as RowNumber,
* FROM [Example].[dbo].[Table_A]


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

Comments and Discussions

GeneralHi Deeksha Shenoy: Thanks a lot. Pin
Md. Marufuzzaman2-Oct-11 19:45
professionalMd. Marufuzzaman2-Oct-11 19:45 
GeneralRe: Hi Deeksha Shenoy: Thanks a lot. Pin
Mubin M. Shaikh26-Aug-13 1:07
professionalMubin M. Shaikh26-Aug-13 1:07 
Hi Deeksha,

Thanks for your update on my articles.
Due to placement of _ for wrapping line, In SQL Script Users are unable to execute script at once, can you please place script as it is withour _ for line break.


I don't have your Email ID, Can You please share it with me ,so i can send email to you whenever needed.

Best Regards.,
Mubin M Shaikh

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.