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
 return results in groups

Author  Topic 

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-04-01 : 15:58:51
I have a large database I want to loop through. How can i make a query that returns the data in groups of 50?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-01 : 16:00:43
use ROW_NUMBER() and GROUP BY. thats all we can say as per brief info posted

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

CrazyT
Yak Posting Veteran

73 Posts

Posted - 2010-04-01 : 16:49:05
i think rownumber will give me the result i want. i want to loop the database and get groups on 10 record.

guess i'll just have to pass the start/finish record
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-04-01 : 18:53:57
Are you referring to paging the data?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-02 : 02:01:49
quote:
Originally posted by CrazyT

i think rownumber will give me the result i want. i want to loop the database and get groups on 10 record.

guess i'll just have to pass the start/finish record



we also can only guess from the amount of info you posted. why dont you post table structure with some sample data if you need more specific help?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-04-02 : 04:15:44
Refer point 4
http://beyondrelational.com/blogs/madhivanan/archive/2007/08/27/multipurpose-row-number-function.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -