Does SQL Server Management Studio 'Messages' output window have a size limit?

14,741

I don't think there is a limit other than any limit imposed by the available memory in the machine. If there is one it is high enough to cater for most potential use cases. Take this SQL as an example:

declare @count int 
set @count = 0 
while (@count < 80000) 
begin
 print cast(@count as varchar(10)) + replicate('x', 7900)
 set @count = (@count + 1) 
end

This print 80000 rows of ~7900 characters. In my test each row is shown in the messages output window (takes a while to run though). So if there is a limit it is quite high.

EDIT

It is also worth mentioning that both PRINT and RAISERROR will truncate if the output string is too long. For example

print replicate('x', 7997) + 'end' -- Output : ...xxxxend
print replicate('x', 7998) + 'end' -- Truncated Output : ...xxxxen

declare @err varchar(max)
set @err = replicate('x', 2044) + 'end' -- Total length 2047
raiserror(@err, 1, 0) -- Output : ...xxxxend

set @err = replicate('x', 2045) + 'end' -- Total length 2048
raiserror(@err, 1, 0) -- Output Truncated with ellipses : ...xxxx...
Share:
14,741
Dog Ears
Author by

Dog Ears

Updated on June 08, 2022

Comments

  • Dog Ears
    Dog Ears about 2 years

    If outputting messages with PRINT or RAISERROR is there a buffer size limit to the window and if so can it be changed.

    I've looked everywhere and but can't see the wood for the trees!

    Calification: I'm intested in the amount of data the output window can display before you start removing the earlier displayed messages. It could be that it just keeps going but there must be some limit, no?