Groups | Blog | Home
all groups > sql server programming > september 2004 >

sql server programming : Limiting The Number of Returned Result Sets


f00_devil NO[at]SPAM yahoo.com
9/8/2004 9:11:59 PM
Hello,

I am running a complicated stored procedure (that calls a few stored
procedures) that returns lots of result sets. I have a few SELECT
statements that I use to initialize loop counters. I use the loop
counters to help me iterate through a local temp table. I have two
questions in relation to this:

1) Is there a way to limit the returned result set(s) to only the
results returned by the last SELECT statement in the SP??

2) I have read that I should limit my use of cursors, but would it be
better to use them here to iterate through my temp table and help cut
down on returned result sets? I need this SP to run fairly quick, and
it is quite complicated, so how much would the cursors bog my server
down?

Thanks for your time and help on this matter, it's much appreciated.

Mark Magpayo
David Portas
9/9/2004 7:04:24 AM
[quoted text, click to view]

Better not to iterate at all - either in a cursor or otherwise. Why not
write a single SELECT statement or SP that returns the entire set of
results? Post DDL, sample data and your existing code if you need help.

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button