How to print VARCHAR(MAX) using Print Statement?

I know it’s an old question, but what I did is not mentioned here.

For me the following worked (for up to 16k chars)

DECLARE @info NVARCHAR(MAX)

--SET @info to something big

PRINT CAST(@info AS NTEXT)

If you have more than 16k chars you can combine with @Yovav’s answer like this (64k should be enough for anyone 😉

    print cast( substring(@info, 1, 16000) as ntext )
    print cast( substring(@info, 16001, 32000) as ntext )
    print cast( substring(@info, 32001, 48000) as ntext )
    print cast( substring(@info, 48001, 64000) as ntext )

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)