Unanswered: Why can varchar datatype variable only 4000 byte?
Why can varchar datatype variable only 4000 byte?
in a storedprocedure
declare @aa varchar(8000)
when the length is more than 4000 ,the data in the behind will be lost
My guess is that @otherinfo is nvarchar type. Nvarchar has higher precedence than varchar, so the result of an operation (concatenation in this case) will take the type of the operand with higher precedence. The result is then implicitly converted to the type of the variable receiving the result.
declare @aa varchar(8000), @otherinfo nvarchar(4000)
set @aa = replicate('X',4000)
set @otherinfo = @aa
set @aa = @aa + @otherinfo