[英]Text overflow when using nvarchar(max)?
I've run into a strange situation that seems to involve long text overflowing. 我遇到了一种奇怪的情况,似乎涉及长文本溢出。 I'm using
fn_pcre_replace
(from the xp_pcre extended stored procedure ) on an nvarchar(max)
column, and when I replace with more characters than were there originally, it returns NULL if the original string was over 8000 characters long. 我在
nvarchar(max)
列上使用fn_pcre_replace
(来自xp_pcre扩展存储过程 ),并且当我替换的字符多于原始字符时,如果原始字符串的长度超过8000个字符,则返回NULL。
For example, this 例如这个
Select master.dbo.fn_pcre_replace(Overview,'a', 'X')
from ProjectContent
works as expected, but this 可以正常工作,但这
Select master.dbo.fn_pcre_replace(Overview,'a', 'XXX')
from ProjectContent
returns NULL in most cases (apparently, wherever Len(Overview)>8000
). 在大多数情况下(显然,
Len(Overview)>8000
)返回NULL。
Is this a limitation of xp_pcre
, or is there something I can do in my SQL to make this work? 这是
xp_pcre
的限制,还是我可以在SQL中做一些事情来实现此目的?
This is a limitation of xp_pcre
. 这是
xp_pcre
的限制。 Looking at the source: 看源:
switch (bType)
{
case SRVBIGCHAR:
case SRVBIGVARCHAR:
break;
default:
throw XpException(
StringBuilder()
<< "Invalid data type on parameter "
<< paramNum
<< " (should be CHAR or VARCHAR)."
);
}
I can conclude these two values (from <srv.h>
) permit up to a maximum of 8000 characters. 我可以断定这两个值(来自
<srv.h>
)最多允许8000个字符。 SRVBIGVARCHAR is SRVBIGVARCHAR现为
Variable-length character data type, length 0 to 8000 bytes.
可变长度字符数据类型,长度为0到8000个字节。
You would need to update the source and recompile with support for SRVTEXT or SRVVARCHAR so it is not a limiting factor when using external procedures. 您将需要更新源代码并重新编译以支持SRVTEXT或SRVVARCHAR,因此在使用外部过程时,这不是限制因素。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.