SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Store proceure with multiple result sets


Store proceure with multiple result sets

Author
Message
Krishna1
Krishna1
SSC Eights!
SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)

Group: General Forum Members
Points: 848 Visits: 556
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
OTF
OTF
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1300 Visits: 4128
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?
Krishna1
Krishna1
SSC Eights!
SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)SSC Eights! (848 reputation)

Group: General Forum Members
Points: 848 Visits: 556
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
OTF
OTF
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1300 Visits: 4128
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?
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search