• Aleksandr,

    The truncation happens in the concatenation of the hyphens to N'hello', step 2 in my previous post. It's truncated because the string 'hello' is cast as National characters, so the concatenation is kept as double-bytes with a limit of 4000. This is before the string is assigned to the local variable, so even though @C can hold more, the 4000 characters is all that is sent to it.

    Again, try it out.....

    declare @C nvarchar(max)

    set @C = Convert(nvarchar(max), N'hello') + replicate('-',9500)

    print len(@c)

    set @C = Convert(nvarchar(max), N'hello') + convert(nvarchar(max),replicate('-',9500))

    print len(@c)

    set @C = Convert(nvarchar(max), N'hello') + replicate(convert(nvarchar(max),'-'),9500)

    print len(@c)

    set @C = N'hello' + replicate(convert(nvarchar(max),'-'),9500)

    print len(@c)