我有一个过程,其中有一个如下所示的选择语句:
CREATE PROCEDURE pr_test
as
SELECT * from SOURCETABLE
我可以通过任何机会执行存储过程pr_test来插入临时表吗?
答案 0 :(得分:2)
您可以使用INSERT EXEC
declare @t results (field1 int, ....)
insert @t (field1,...)
exec pr_test
答案 1 :(得分:0)
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