• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 454
  • Last Modified:

How to insert stored procedure fields into temp table

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
VBBRett
Asked:
VBBRett
  • 2
1 Solution
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Thanks for the grade. Good luck with your project.  -Jim
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now