|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Results of EXEC into table?I have a feeling I already know the answer to this, but is there any way
that I can use the results of an SP in another query? In other words, I have an SP that outputs a table, and I want to use that table as an input to a SELECT... -mdb
http://www.sommarskog.se/share_data.html
--
Show quote
Andrew J. Kelly SQL MVP "Michael Bray" <mbray@makeDIntoDot_ctiusaDcom> wrote in message
news:Xns9742A6DE6C0EDmbrayctiusacom@207.46.248.16... >I have a feeling I already know the answer to this, but is there any way > that I can use the results of an SP in another query? In other words, I > have an SP that outputs a table, and I want to use that table as an input > to a SELECT... > > -mdb One method is to create a target table with schema matching the proc results
and then load with INSERT...EXEC. For example: CREATE Table #MyTable(Col1 int) INSERT INTO #MyTable EXEC MyProc See the Books Online for more info. -- Show quoteHope this helps. Dan Guzman SQL Server MVP "Michael Bray" <mbray@makeDIntoDot_ctiusaDcom> wrote in message news:Xns9742A6DE6C0EDmbrayctiusacom@207.46.248.16... >I have a feeling I already know the answer to this, but is there any way > that I can use the results of an SP in another query? In other words, I > have an SP that outputs a table, and I want to use that table as an input > to a SELECT... > > -mdb |
|||||||||||||||||||||||