Solved

How to insert stored procedure fields into temp table

Posted on 2013-12-25
2
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

Suggested Solutions

Audit has been really one of the more interesting, most useful, yet difficult to maintain topics in the history of SQL Server. In earlier versions of SQL people had very few options for auditing in SQL Server. It typically meant using SQL Trace …
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

734 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