Answers:
您可以OPENQUERY
利用来绕过8000个字符的限制EXECUTE AT
,如下所示:
DECLARE @myStatement VARCHAR(MAX)
SET @myStatement = 'SELECT * FROM TABLE WHERE CHARACTERS.... ' -- Imagine that's longer than 8000 characters
EXECUTE (@myStatement) AT LinkedServerName
为了确保这不会引发错误,您需要RPC OUT
通过发出以下命令在链接服务器上启用该选项:
EXEC master.dbo.sp_serveroption @server=N'LinkedServerName', @optname=N'rpc out', @optvalue=N'true'
或在GUI中启用它: