Kindly Clarify: How to access multiple result set data from a Stored procedure?

Posted by Jasminej under Sql Server on 4/27/2012 | Points: 10 | Views : 868 | Status : [Member] | Replies : 2
How to access multiple result set data from a Stored procedure

I have written one stored procedure,
It returns 3 result sets.

How can I access the only Second resultset from sql server ?

Thank You




Responses

Posted by: Pandians on: 4/27/2012 [Member] [MVP] Silver | Points: 25

Up
0
Down
In SQL Server Denali, You can use "RESULT SETS". But, rest of the other versions....
Create Proc USP_Sample

As
Begin
Set Nocount On

Select 1 [RSet], 'SQL' [Name]

Select 2 [RSet],'Server' [Name]
Union
Select 2 [RSet],'BI' [Name]
Union
Select 2 [RSet],'Admin' [Name]

Select 3 [RSet], 'Developer' [Name]
End
Go
Normally, It have 3 result sets!

To access the second result set..
Create Table #Result (Rset Int, Name Varchar(50))


Insert #Result
Exec USP_Sample

Select * from #Result Where RSet = 2

Drop Table #Result


Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Jasminej, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jasminej on: 4/30/2012 [Member] Starter | Points: 25

Up
0
Down
Great Thanks Pandians

Jasminej, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response