Solved

How to insert stored procedure fields into temp table

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Long way back, we had to take help from third party tools in order to encrypt and decrypt data.  Gradually Microsoft understood the need for this feature and started to implement it by building functionality into SQL Server. Finally, with SQL 2008, …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

707 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now