Compare these two statements
select stuff(convert(varchar(max),replicate('a', 10000)),8001,1,'b')
select stuff(convert(varchar(max),replicate('a', 10000)),8000,1,'b')
Output
aaaaaaaaaaaaaaaaaaaaaaaa...
NULL
Books Online says start can be of type bigint.
Why such a large range if it won't even work for 8001?
If the behaviour is different between 2005, 2008, 2008 R2 and Denali, then I would like to know the actual behaviour of each version.
REPLICATE ('a', 10000)
will produce a 8000 characters string:
If string_expression is not of type varchar(max) or nvarchar(max), REPLICATE truncates the return value at 8,000 bytes. To return values greater than 8,000 bytes, string_expression must be explicitly cast to the appropriate large-value data type.
Try REPLICATE (cast('a' as varchar(max)), 10000)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With