Solved

How to insert stored procedure fields into temp table

Posted on 2013-12-25
2
432 Views
Last Modified: 2014-01-28
I am looking for a way to insert all fields and data of a stored procedure into a temp table.  How can I do that?  I am trying different things but it is not working.  Thanks!
0
Comment
Question by:VBBRett
  • 2
2 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 39739642
You mean like .... here's a SP
CREATE PROC foo  AS

SELECT 1 as col1, 2 as col2
UNION ALL
SELECT 3, 4
UNION ALL
SELECT 5, 6
GO

Open in new window

... and here's T-SQL to insert the results of SP foo into a temp table ...
CREATE TABLE #tmp (col1 int, col2 int) 

INSERT INTO #tmp (col1, col2)
exec foo

SELECT * FROM #tmp

Open in new window

0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 39814914
Thanks for the grade. Good luck with your project.  -Jim
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question