Sql server 如何将SP结果放入SQL server中的临时表中

Sql server 如何将SP结果放入SQL server中的临时表中,sql-server,temp-tables,Sql Server,Temp Tables,我试过这个: select * into #temp124 exec usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1 但这不起作用。有人能帮我将SP结果放入临时表吗?首先启用几个选项: sp_configure 'Show Advanced Options', 1 GO RECONFIGURE GO sp_configure 'Ad Hoc Distributed Queries', 1 GO RECONF

我试过这个:

select * into #temp124
exec usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1

但这不起作用。有人能帮我将SP结果放入临时表吗?

首先启用几个选项:

sp_configure 'Show Advanced Options', 1
GO
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO
RECONFIGURE
GO
然后您可以使用:

创建表以手动存储SP数据的另一种方法,但您应该确切知道此SP返回的数据

CREATE TABLE #temp124 (
    Col1 int,
    Col2 nvarchar=(max),
    ...etc
)

INSERT INTO #temp124
EXEC usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1

请显示错误消息或描述意外行为。
CREATE TABLE #temp124 (
    Col1 int,
    Col2 nvarchar=(max),
    ...etc
)

INSERT INTO #temp124
EXEC usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1