Reputation: 2700
I have a procedure which has a select statement as below:
CREATE PROCEDURE pr_test
as
SELECT * from SOURCETABLE
Can I insert into a temp table by executing the stored procedure pr_test by any chance?
Upvotes: 0
Views: 1091
Reputation: 51494
You can use INSERT EXEC
declare @t results (field1 int, ....)
insert @t (field1,...)
exec pr_test
Upvotes: 2
Reputation: 5588
CREATE PROCEDURE pr_test
as
begin
CREATE TABLE #TibetanYaks(
YakID int,
YakName char(30) )
INSERT INTO #TibetanYaks (YakID, YakName)
SELECT YakID, YakName
FROM dbo.Yaks
WHERE YakType = 'Tibetan'
-- Do some stuff with the table
drop table #TibetanYaks
end
Upvotes: 0