Advertisement

05.29.2008 at 06:33AM PDT, ID: 23441299
[x]
Attachment Details

Stored procedure returning multiple results sets ->single result set

Asked by GabrielaPopa in MS SQL Server, SQL Server 2005

Tags: Microsoft, SqlServer 2005, 2005, T-SQL

I have the following stored procedure (see code snippet) ,  which returns mutiple datasets, because I would like to use it in Reporting Services I need to combine the result sets into only one.

Could you please help me out with this, as I am not a SQL specialist.Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
ALTER PROCEDURE [dbo].[GetData] 
	(
	@param varchar(4000),
	@sp varchar (100)
)
	
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	
	Declare myCursor Cursor FOR
	SELECT Item
	from TSqlSplit(@param, default,default)
	FOR Read Only
 
	DECLARE @p_id int
	OPEN myCursor
 
	FETCH Next FROM myCursor INTO @p_id
	WHILE(@@fetch_status <> -1)
	
	BEGIN
		EXEC @sp @p_id
		Fetch Next From myCursor INTO @p_id	
	END
 
	CLOSE portfolios
	DEALLOCATE portfolios
 
 
END
[+][-]05.29.2008 at 06:35AM PDT, ID: 21668935

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 06:37AM PDT, ID: 21668956

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.29.2008 at 06:47AM PDT, ID: 21669037

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.12.2008 at 12:34AM PDT, ID: 21766909

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, SQL Server 2005
Tags: Microsoft, SqlServer 2005, 2005, T-SQL
Sign Up Now!
Solution Provided By: GabrielaPopa
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628