Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Store proceure with multiple result sets Expand / Collapse
Author
Message
Posted Tuesday, April 30, 2013 6:54 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 9:12 PM
Points: 215, Visits: 542
Dear All

I have one procedure PROC1 wich resturn multiple result sets. No of coulmn and Datatype of the result set are not same.

I want to access the result of PROC1 from another proceure PROC2. How do i do it?

Regards
Krishna
Post #1447998
Posted Tuesday, April 30, 2013 10:00 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
Krishna1 (4/30/2013)
Dear All

I have one procedure PROC1 wich resturn multiple result sets. No of coulmn and Datatype of the result set are not same.

I want to access the result of PROC1 from another proceure PROC2. How do i do it?

Regards
Krishna


You'd probably need to use INSERT...EXEC within PROC2 to do this.
I believe you can also do it with OPENROWSET but I wouldn't really advise that approach.

Are you trying to access the resultsets as one set?
Post #1448123
Posted Tuesday, April 30, 2013 11:11 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, April 02, 2014 9:12 PM
Points: 215, Visits: 542
Hi

I am uisng following code. How do create a table for insert into when 2 resul sets are differnt? Please advice.

CREATE procedure PROC1 as
begin
Select 'aaa',1

select 1,2.22,'xxx'
end
go
DROP PROCEDURE PROC2
go
Create procedure PROC2 as
BEGIN
INSERT INTO #temp
EXECUTE PROC1

SELECT * FROM #temp
END

go
execute PROC2

Regards
Krishna
Post #1448154
Posted Tuesday, April 30, 2013 1:34 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, October 31, 2013 3:44 AM
Points: 314, Visits: 4,128
Krishna1 (4/30/2013)
Hi

I am uisng following code. How do create a table for insert into when 2 resul sets are differnt? Please advice.

CREATE procedure PROC1 as
begin
Select 'aaa',1

select 1,2.22,'xxx'
end
go
DROP PROCEDURE PROC2
go
Create procedure PROC2 as
BEGIN
INSERT INTO #temp
EXECUTE PROC1

SELECT * FROM #temp
END

go
execute PROC2

Regards
Krishna


I think you might find that INSERT...EXEC will let you down in that instance. I don't believe you can capture multiple resultsets with it.
In fact, as I think about it, the only way that comes to my mind to handle that kind of thing anywhere near gracefully would be with the CLR.
I'm assuming you don't have the option of altering the Procedure itself?
Post #1448219
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse