Unix Technical Forum

Doing a SELECT INTO using a Stored Proc as the data source

This is a discussion on Doing a SELECT INTO using a Stored Proc as the data source within the SQL Server forums, part of the Microsoft SQL Server category; --> I have a stored proc that returns a resultset. I would like to deposit that resultset into a table. ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-11-2008, 09:41 PM
Deane
 
Posts: n/a
Default Doing a SELECT INTO using a Stored Proc as the data source

I have a stored proc that returns a resultset.

I would like to deposit that resultset into a table. Kind of like a
"SELECT INTO", but using a stored proc.

If I could do this --

SELECT INTO MyTable FROM MyStoredProc

-- I'd be happy.

What are the alternatives?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 05-11-2008, 09:41 PM
Tom van Stiphout
 
Posts: n/a
Default Re: Doing a SELECT INTO using a Stored Proc as the data source

On Sat, 10 May 2008 20:29:14 -0700 (PDT), Deane
<deane.barker@gmail.com> wrote:

Why would you want to store the resultset in a table if you can simply
re-run the sproc?
-Tom.


>I have a stored proc that returns a resultset.
>
>I would like to deposit that resultset into a table. Kind of like a
>"SELECT INTO", but using a stored proc.
>
>If I could do this --
>
>SELECT INTO MyTable FROM MyStoredProc
>
>-- I'd be happy.
>
>What are the alternatives?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-11-2008, 09:41 PM
Plamen Ratchev
 
Posts: n/a
Default Re: Doing a SELECT INTO using a Stored Proc as the data source

You can use OPENQUERY, like:

SELECT * INTO #Tmp FROM OPENQUERY(Loopback, 'EXEC MySp');

Make sure to read Erland Sommarskog's article on some issues with this
approach:
http://www.sommarskog.se/share_data.html#OPENQUERY

Also, if you create the table structure first then you can use INSERT EXEC:

INSERT #Tmp EXEC MySp;

HTH,

Plamen Ratchev
http://www.SQLStudio.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-13-2008, 07:13 PM
Deane
 
Posts: n/a
Default Re: Doing a SELECT INTO using a Stored Proc as the data source

> Why would you want to store the resultset in a table if you can simply
> re-run the sproc?


Because I need to run queries on the resultset, without changing the
stored proc.

Deane
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:33 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com