• The problem is that the base string value must be assigned a datatype in order to be processed before it can be assigned to your variable. Even though that variable is nvarchar(max), the string value itself will default to nvarchar(4000).

    If that value is being assigned concatenated with an nvarchar(max) value, then it will be upconverted itself to nvarchar(max) in order to make the assignment possible to the same datatype.

    The trick here is to concat your big string value to an nvarchar(max) string value before assigning it to the variable, causing the query processor to coerce it to an nvarchar(max):

    DECLARE @EmailMessage1 nvarchar(max)

    select @EmailMessage1 = convert(nvarchar(max), N'') + N' ...lots of text here...'

    Select len(@EmailMessage1)

    Eddie Wuerch
    MCM: SQL