Paging easy in “DENALI” (OFFSET & FETCH OPTION)

Hello friends,
Let’s talk today one more important clause of “DENALI” which is very helpful in fetching records, paging are “OFFSET” & “FETCH”.
It is helpful in performance improvement also.
Just go through below example and it will clear more
Suppose I have state table which have all the state rows of INDIA.


Now with offset clause I can say from where I can start row fetching and FETCH NEXT will give me option how many rows I want.
So suppose I want 5 records after and skip first 2 rows then see below SQL statement
SELECT * FROM state ORDER BY StateName OFFSET 2 ROWS FETCH NEXT FROM 5 ROWS ONLY


Hope you enjoyed it and will use sooner or later.
Thanks & Regards
Rajat Jaiswal

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s