SQL 在OPENQUERY中使用参数
DECLARE @tmptable AS TABLE(ccode nvarchar(20),str1 NVARCHAR(50),str15 NVARCHAR(255),FHGLID NUMERIC)
DECLARE @sql VARCHAR(1000)='CC003'
SET @sql='SELECT * from DATABASE.dbo.getBTXX('''+@sql+''')'
SET @Sql = 'SELECT * FROM OPENQUERY(SVRNAME, ''' + REPLACE(@Sql, '''', '''''') + ''')'
INSERT INTO @tmptable
EXEC(@sql)
SELECT *
FROM @tmptable T
祥: