Multiple ResultSets

This is a discussion on Multiple ResultSets within the sqlserver-programming forums in Microsoft SQL Server category; We have a third party stored proc which returns multiple resultsets. Their format is well defined. Is it possible to capture the multiple resultsets in temp table. Something like insert into #temp exec sp_GetTables thx...

Go Back   Database Forum > Microsoft SQL Server > sqlserver-programming

Database Forums

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 08-27-2008, 08:35 PM
Default Multiple ResultSets

We have a third party stored proc which returns multiple resultsets. Their
format is well defined.
Is it possible to capture the multiple resultsets in temp table. Something
like

insert into #temp
exec sp_GetTables


thx

Reply With Quote
  #2  
Old 08-27-2008, 10:21 PM
Default Re: Multiple ResultSets

I don't believe this is possible in TSQL (could be mistaken), but you could
use a different language to capture and process multiple resultsets from a
sproc.

--
Kevin G. Boles
Indicium Resources, Inc.
SQL Server MVP
kgboles a earthlink dt net


"slg" wrote in message
news:ey8AT2JCJHA.4368-at-TK2MSFTNGP06.phx.gbl...
> We have a third party stored proc which returns multiple resultsets. Their
> format is well defined.
> Is it possible to capture the multiple resultsets in temp table.
> Something like
>
> insert into #temp
> exec sp_GetTables
>
>
> thx



Reply With Quote
  #3  
Old 08-28-2008, 07:20 AM
Default Re: Multiple ResultSets

slg
Do the multiple resultsets have the same number of columns to return? If it
does not you are out of luck.
If it does, create a temporary table and insert into eacgh result set but
it is messy




"slg" wrote in message
news:ey8AT2JCJHA.4368-at-TK2MSFTNGP06.phx.gbl...
> We have a third party stored proc which returns multiple resultsets. Their
> format is well defined.
> Is it possible to capture the multiple resultsets in temp table.
> Something like
>
> insert into #temp
> exec sp_GetTables
>
>
> thx



Reply With Quote
  #4  
Old 08-28-2008, 12:14 PM
Default Re: Multiple ResultSets


I think you can only capture the first resultset.

Even if the columns are identical from the resultsets, I still think you can
only capture the 1st resultset.

............




"slg" wrote in message
news:ey8AT2JCJHA.4368-at-TK2MSFTNGP06.phx.gbl...
> We have a third party stored proc which returns multiple resultsets. Their
> format is well defined.
> Is it possible to capture the multiple resultsets in temp table.
> Something like
>
> insert into #temp
> exec sp_GetTables
>
>
> thx



Reply With Quote
  #5  
Old 08-28-2008, 06:21 PM
Default Re: Multiple ResultSets

Wrong!

-- If the resultsets are all the same structure and there is something about
them which distinguishes them, you can
-- capture them in a table and filter them afterwards eg

DROP TABLE temp
GO
CREATE TABLE temp ( source_id INT, val1 VARCHAR(10), val2 VARCHAR(10),
date_added DATETIME DEFAULT( GETDATE() ) )
GO
CREATE VIEW viw_temp AS SELECT source_id, val1, val2 FROM temp
GO

DROP PROC usp_test
GO
CREATE PROC usp_test

AS

SELECT 1 AS source, 10, 100

SELECT 2 AS source, 20, 200
GO

-- Capture all results of the stored proc
INSERT INTO viw_temp
EXEC usp_test
GO

-- Show everything
SELECT *
FROM temp
GO

-- Filter resultset
SELECT *
FROM temp
WHERE source_id = 1
GO

Or see here with a CLR method:
http://groups.google.com/group/micro...55f2e?lnk=raot

"sloan" wrote:

>
> I think you can only capture the first resultset.
>
> Even if the columns are identical from the resultsets, I still think you can
> only capture the 1st resultset.
>
> ............
>
>
>
>
> "slg" wrote in message
> news:ey8AT2JCJHA.4368-at-TK2MSFTNGP06.phx.gbl...
> > We have a third party stored proc which returns multiple resultsets. Their
> > format is well defined.
> > Is it possible to capture the multiple resultsets in temp table.
> > Something like
> >
> > insert into #temp
> > exec sp_GetTables
> >
> >
> > thx

>
>
>

Reply With Quote
  #6  
Old 09-04-2008, 02:47 PM
Default Re: Multiple ResultSets

Ouch. My bad (to the original OP).

Thanks for the correction.


"Bob" wrote in message
news:4EFC9722-5563-4C74-955E-0A74E9D85CBD-at-microsoft.com...
> Wrong!
>
> -- If the resultsets are all the same structure and there is something
> about
> them which distinguishes them, you can
> -- capture them in a table and filter them afterwards eg
>
> DROP TABLE temp
> GO
> CREATE TABLE temp ( source_id INT, val1 VARCHAR(10), val2 VARCHAR(10),
> date_added DATETIME DEFAULT( GETDATE() ) )
> GO
> CREATE VIEW viw_temp AS SELECT source_id, val1, val2 FROM temp
> GO
>
> DROP PROC usp_test
> GO
> CREATE PROC usp_test
>
> AS
>
> SELECT 1 AS source, 10, 100
>
> SELECT 2 AS source, 20, 200
> GO
>
> -- Capture all results of the stored proc
> INSERT INTO viw_temp
> EXEC usp_test
> GO
>
> -- Show everything
> SELECT *
> FROM temp
> GO
>
> -- Filter resultset
> SELECT *
> FROM temp
> WHERE source_id = 1
> GO
>
> Or see here with a CLR method:
> http://groups.google.com/group/micro...55f2e?lnk=raot
>
> "sloan" wrote:
>
>>
>> I think you can only capture the first resultset.
>>
>> Even if the columns are identical from the resultsets, I still think you
>> can
>> only capture the 1st resultset.
>>
>> ............
>>
>>
>>
>>
>> "slg" wrote in message
>> news:ey8AT2JCJHA.4368-at-TK2MSFTNGP06.phx.gbl...
>> > We have a third party stored proc which returns multiple resultsets.
>> > Their
>> > format is well defined.
>> > Is it possible to capture the multiple resultsets in temp table.
>> > Something like
>> >
>> > insert into #temp
>> > exec sp_GetTables
>> >
>> >
>> > thx

>>
>>
>>



Reply With Quote
Reply


Thread Tools
Display Modes



All times are GMT -4. The time now is 09:02 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Integrated by bbpixel2008 :: jvbPlugin R1013.368.1

Search Engine Friendly URLs by vBSEO 3.1.0
vB Ad Management by =RedTyger=
In an effort to better serve ads to our visitors, cookies are used on Mydatabasesupport.com. For more information, check out our Privacy Policy.