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:Try
REPLICATE (cast('a' as varchar(max)), 10000).