Unix Technical Forum

SP returning a table -- ?

This is a discussion on SP returning a table -- ? within the SQL Server forums, part of the Microsoft SQL Server category; --> There's an SP that in effect returns a table -- it loops and executes statements like SELECT @field1, @Field2, ...


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

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 05:40 PM
Jim Geissman
 
Posts: n/a
Default SP returning a table -- ?

There's an SP that in effect returns a table -- it loops and executes
statements like SELECT @field1, @Field2, @Field2

Can I capture its results in a table? I know that if it were a FUNCTION
that returned a table, that would be simple:

INSERT ResultsTable SELECT * FROM dbo.Function (@Param1, @Param2)

But how to do that if the code is a procedure rather than a function?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 05:40 PM
John Bell
 
Posts: n/a
Default Re: SP returning a table -- ?

Hi

Check out the form of insert statement that calls exec

INSERT INTO <TABLE> execute_statement

i.e INSERT INTO <TABLE> EXEC stored_procedure

http://msdn.microsoft.com/library/de...asp?frame=true

John


"Jim Geissman" <jim_geissman@countrywide.com> wrote in message
news:b84bf9dc.0308291355.6af690b6@posting.google.c om...
> There's an SP that in effect returns a table -- it loops and executes
> statements like SELECT @field1, @Field2, @Field2
>
> Can I capture its results in a table? I know that if it were a FUNCTION
> that returned a table, that would be simple:
>
> INSERT ResultsTable SELECT * FROM dbo.Function (@Param1, @Param2)
>
> But how to do that if the code is a procedure rather than a function?



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 01:01 PM.


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