Generate auto row number for a table

This is a really a great experience for me, because I got an opportunities 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 issues, because I want the data paging must be server side and data shorting will be client side where I must concern on the application performance, each table contain more than 10 thousand of rows. So finally discover 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]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s