SQL 如何在 Openrowset 中使用 table 变量
SQL How to use table variable in Openrowset
我使用openrowset
执行OperatorsCalc
程序。
如何发送声明的参数:
@operators
(OperatorTableType)
@number
(整数)
进入由 openrowset
?
执行的过程
DECLARE @operators OperatorTableType
insert into @operators values ('Mr James')
insert into @operators values ('Mr Johnny')
DECLARE @number int = 3
SELECT *
INTO #MyTempTableForOperators
FROM
OPENROWSET('SQLNCLI', 'Server=apollo;Trusted_Connection=yes;',
'SET FMTONLY OFF;
SET NOCOUNT ON;
EXEC servername.dbname.dbo.OperatorsCalc @number @operators') -- I want to sent parameters @operators and @number in here
select * from #MyTempTableForOperators
尝试使用linked server,但如果有嵌套insert into temp.
可能会失败
CREATE TABLE #temp (...)
INSERT INTO #temp(...)
EXECUTE [servername].[dbname].[dbo].[OperatorsCalc] @number @operators;
另请阅读 How to Share Data between Stored Procedures by Erland Sommarskog。
关于OPENQUERY的章节不错。
我使用openrowset
执行OperatorsCalc
程序。
如何发送声明的参数:
@operators
(OperatorTableType)@number
(整数)
进入由 openrowset
?
DECLARE @operators OperatorTableType
insert into @operators values ('Mr James')
insert into @operators values ('Mr Johnny')
DECLARE @number int = 3
SELECT *
INTO #MyTempTableForOperators
FROM
OPENROWSET('SQLNCLI', 'Server=apollo;Trusted_Connection=yes;',
'SET FMTONLY OFF;
SET NOCOUNT ON;
EXEC servername.dbname.dbo.OperatorsCalc @number @operators') -- I want to sent parameters @operators and @number in here
select * from #MyTempTableForOperators
尝试使用linked server,但如果有嵌套insert into temp.
可能会失败CREATE TABLE #temp (...)
INSERT INTO #temp(...)
EXECUTE [servername].[dbname].[dbo].[OperatorsCalc] @number @operators;
另请阅读 How to Share Data between Stored Procedures by Erland Sommarskog。 关于OPENQUERY的章节不错。