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 @lRowID int, @txtExcp varchar(max)
set @lRowID = 163020	-- set the value of the identity column of the row of interest

-- select the value from the column into our varchar(max) variable.
SELECT @txtExcp = a.txtException
from MyData a
where a.lRowID = @lRowID

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


Last modified by Mohit @ 4/13/2025 7:47:47 PM