0
我已經試過這樣:我怎樣才能把SP結果到臨時表中的SQL服務器
select * into #temp124
exec usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1
但是,這是行不通的。有人可以幫助我將SP結果放入臨時表中嗎?
我已經試過這樣:我怎樣才能把SP結果到臨時表中的SQL服務器
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
然後你可以使用OPENROWSET:
SELECT * INTO #Temp124
FROM OPENROWSET('SQLNCLI', 'Server=(local)\InstanceName;Trusted_Connection=yes;',
'EXEC usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1')
另一種方法來創建表的手動存儲來自SP的數據,但你應該知道什麼樣的數據本SP返回。
CREATE TABLE #temp124 (
Col1 int,
Col2 nvarchar=(max),
...etc
)
INSERT INTO #temp124
EXEC usp_GetTagDetails @UserId=1,@IsActiveOnly=1,@IsParentPathRequired=1
請顯示錯誤信息或描述意外行爲。 – YakovL