我想执行大约10,000个字符的动态SQL语句。
当我使用sp_executesql时,如下所示:
DECLARE @stmt varchar(MAX)
SET @stmt = 'xxxxxxxx.................' which is about 10,000 characters
EXEC sp_executesql @stmt我得到了以下错误
The character string that starts with ' select t1.e_reference xxxxxxxxxxx' is too long. Maximum length is 8000. 据我所知,我们可以使用sp_executesql来执行非常长的语句,不是吗?
我使用的是64位SQL Server 2008企业版。
我如何才能做到这一点?谢谢。
发布于 2012-12-10 19:06:41
根据您在帖子中的回复,您使用的是linked server。8000 char的限制不是由sp_executesql提出的,而是由您可能在变量@stmt中使用的OPENQUERY提出的。
MSDN对OPENQUERY的论点这样说:
'
query‘是在链接服务器中执行的查询字符串。string的最大长度为8KB。
http://msdn.microsoft.com/en-us/library/ms188427.aspx
要绕过这一步,您可能可以使用
execute (@query) at oracle_linked_serverhttps://stackoverflow.com/questions/8151121
复制相似问题