我有一个程序,其中有一个 select 语句,如下所示:
CREATE PROCEDURE pr_test
as
SELECT * from SOURCETABLE
我可以通过执行存储过程 pr_test 插入临时表吗?
我有一个程序,其中有一个 select 语句,如下所示:
CREATE PROCEDURE pr_test
as
SELECT * from SOURCETABLE
我可以通过执行存储过程 pr_test 插入临时表吗?
您可以使用INSERT EXEC
declare @t results (field1 int, ....)
insert @t (field1,...)
exec pr_test
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