January 7, 2009 at 12:39 pm
I have a cursor that queries on a table based on a list of IDs.
The problem I have is for each ID I am getting a seperate result set.
I want to display the results of each fetch combined in a single result set.
Can somebody guide?
January 7, 2009 at 12:48 pm
You'd have to store the individual results in some sort of temporary storage (table variable, temp table). Better yet, don't use a cursor. If you are cursoring through a set of data, but you ultimately want to view a set of data as your final results, I would say that you don't need the cursor at all. In fact, using the cursor along with the temporary storage will prove to be slow and cumbersome compared to a set based operation.
If you want help, post an example of what you are doing and we'll help out. Since you're fairly new, here's a link on how to create a quality post for quality help:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
January 7, 2009 at 1:02 pm
It sounds like you need to get rid of the cursor and just run a query using the data in a join or possibly as part of the where clause.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
January 7, 2009 at 1:03 pm
Thanks.
I tried eliminating the cursor and it works fine now.
Sorry about my post...I will observe the pattern in my next posting.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply