In SSMS when I try to execute:
SELECT CONVERT(VARCHAR(MAX), REPLICATE('a',9000))
I see only the first 8000 characters displayed. The settings Tool >> Options >> Query Results >> Sql Server >> Results to Grid is set to 65534 and Results to Text is set to 8192.
Also when I try to run this from SQLCMD
sqlcmd -S Server -E -y 0 -Q "SELECT CONVERT(VARCHAR(MAX), REPLICATE('a',9000))" -o out.txt
I see only 8000 charecters.
The flag -y 0 is supposed to set it up to 1 MB. But I do not more than 8000 characters.
What could be the problem?
thanks,
_UB
REPLICATE output is based on the datatype input. So this explains sqlcmd.
If string expression is not of type varchar(max) or nvarchar(max), REPLICATE truncates the return value at 8,000 bytes. To return values greater than 8,000 bytes, string expression must be explicitly cast to the appropriate large-value data type.
So, use this SELECT REPLICATE(CONVERT(VARCHAR(MAX), 'a'), 9000)
And SSMS has never shown all text data (nor did Query Analyzer)