0

我有一个程序,其中有一个 select 语句,如下所示:

CREATE PROCEDURE pr_test
as 
SELECT  * from SOURCETABLE

我可以通过执行存储过程 pr_test 插入临时表吗?

4

2 回答 2

2

您可以使用INSERT EXEC

 declare @t results (field1 int, ....)

 insert @t (field1,...)
 exec pr_test 
于 2012-10-05T09:47:33.097 回答
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
于 2012-10-05T09:45:56.100 回答