Solved

How to insert stored procedure fields into temp table

Posted on 2013-12-25
2
436 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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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…

821 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