I have built up the T-SQL variable @Foo over many lines of code.
If @Foo is declared as VarChar(MAX), the immediately following PRINT statement outputs what I expect (5,421 characters).
However, the further following EXECUTE statement fails because it requires an NVarChar parameter.
When I change the declaration of @Foo to NVarChar(MAX), the PRINT statement only prints out a subset (3,902 characters) of what I am expecting. The output is truncated.
@Foo is the concatenation of a number of variables, all of which are VarChar(MAX). Before I go up the chain, changing all predecessor variables as NVarChar(MAX), to continue testing, I was wondering if anyone has an idea about this inconsistent behaviour.
PRINT @Foo
EXECUTE [master].[sys].[sp_executesql] @Foo
Many thanks.
Keith