Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to fetch records how much you want??

Author  Topic 

Jabez
Starting Member

19 Posts

Posted - 2007-12-03 : 23:03:04
Hi Folks,

How do I right queries to fetch first 10 records, then next 10 and so on..

My table structure is as follows:
Columns
--------
MPAD_ID (IDENTITY INCREMENT YES )
MPAD_EmpCode (Employee Code)
MPAD_Date (Date)
MPAD_Status (Attendance Status i.e. P, A, etc)

Sample Records for the same is given below

MPAD_ID MPAD_EmpCode MPAD_Date MPAD_Status
------- ------------ ---------- -----------
1 1001 11/01/2007 P
2 1001 11/02/2007 P
3 1001 11/03/2007 A
... .. .. ..
14 1002 11/01/2007 P
15 1002 11/02/2007 A
16 1002 11/03/2007 P

Please help me out in writing out this query.

Thanks

Jabez.

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2007-12-03 : 23:45:04
Sounds like you are talking about "paging". Check out this article and if you still want more try a forum search on "paging"
http://www.sqlteam.com/article/server-side-paging-using-sql-server-2005

Be One with the Optimizer
TG
Go to Top of Page

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2007-12-04 : 04:35:42
Hi!

It's better to do this work through your front end.suppose if you are using.NET then use data grid (paging) option.

by
Kiruthika!
http://www.ictned.eu
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2007-12-04 : 08:50:54
quote:
Originally posted by kiruthika

It's better to do this work through your front end.suppose if you are using.NET then use data grid (paging) option.

Of course every implementation needs to be looked at individually but generally speaking there can be good reasons do server side paging.
If the user request results in 20,000 rows but the user typically only wants to see the 1st 10 rows then you will move 19,990 rows out to the client unnecessarily.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -