Monday, September 26, 2016

Generic script for selecting columns from result of stored proc

CREATE PROCEDURE SampleSP
AS
SELECT 1 AS Col1, 2 AS Col2
UNION
SELECT 11, 22
GO


CREATE TABLE #TempTable (Col1 INT, Col2 INT)
GO
INSERT INTO #TempTable
EXEC SampleSP
GO

SELECT *
FROM #TempTable
GO

DROP TABLE #TempTable
DROP PROCEDURE SampleSP
GO

No comments:

Post a Comment