I am creating a dynamic query in stored procedure, and when I try to print that dynamic query, it only prints a part of the whole query.
My variable that holds the whole dynamic query is declared like below
DECLARE @SQL NVARCHAR(MAX) When I print the variable's length like below, It gives the length of the whole query, which is good.
PRINT LEN(@SQL) But, when I print the script itself, It prints only a part of the whole query.
PRINT @SQL I also tried to print it like below
PRINT CONVERT(NVARCHAR(MAX),@SQL) Why it only prints first 4000chars? What am I doing wrong?
SELECTquery results will yield the full value of the field.Why it only prints first 4000chars?Because this is howPRINTworks, which is written in the docs very clearly.