There is a limit to the print output on MS SQL server (I'm using SQL Server 2014).
I've got my Maximum number of characters displayed in each column set to 8192 (the max). When I try to set a variable to a long string and print it, it gets truncated. With output set to text:
declare @text nvarchar(max)
set @text = (
select definition
from sys.sql_modules
where object_id = object_id(N'NameOfALargeStoredProcedure')
)
print @text
This will return about 4K of the characters. If I change @text
to varchar
(instead of nvarchar
) I get around 8K characters.
The definition of the procedure is much larger than 8K. I need to print the entire text of a string that is larger than 8K.
I know SQL Server has a built-in script object feature. What I need to print may not be a database object: I need to print an arbitrary string.