Print Varchar(max) field contents

The following illustrates an example of how to output the full text of the contents stored in a varchar(max) column in SQL Management Studio.
-- declare some variables
DECLARE @rowID int, @bigText nvarchar(max)
set @rowID = 1055	-- set the value of the identity column of the row of interest



-- select the value from the column into our varchar(max) variable.
SELECT @bigText = a.RequestBody
from MyTable a
where a.RowID = @rowID


-- cast the varchar(max) to a text during the print to the output
PRINT convert(ntext, @bigText)
print ''
print ''



-- use the rest of this if the output is greater than 16000 characters
declare @idx int = 1
	, @size int = 16000
	, @fulllen int = len(@bigText)

while (@idx < @fulllen)
begin

	print convert(text, substring(@bigText, @idx, @size))
	set @idx = @idx + @size

end


Last modified by Mohit @ 2/26/2026 10:09:35 AM