5

How can i clean output window in SSMS using t-sql syntax? Is it possible ? Do you know any workarounds ?

2
  • Why do you want to do this? What are you trying to achieve? Jul 26, 2016 at 5:11
  • @SirSwears-a-lot - I wasn't the OPer, but I have a script that builds a system then populates it with data. That process produces dozens of panels on the "results" tab. My last statement calls on a procedure that has been created - as a means to check the results of the script. It would be nice to clear out the dozens of un-required results before the one statement that will give me useful information. Apr 8, 2020 at 6:05

3 Answers 3

10

This is not possible to do within the context of a single execution of whatever is in the Query pane. T-SQL commands are not interpreted by SSMS. They are sent to SQL Server to be processed. Only a GO [execution_count] statement (batch separator, GO being the default but can be changed) and a subset of the SQLCMD commands -- !!, :exit, :quit, :r, :setvar, :connect, :on error, :error, and :out -- are captured and processed by SSMS (and are not sent to SQL Server).

Also, there aren't even any internal SSMS commands to clear either the Results tab or the Messages tab.

So, if there are any results being returned, they will be in the Results tab at the end of the execution no matter what.

BUT, after that execution ends, you can manually clear both the "Results" and "Messages" tabs by highlighting an empty line (or even just a space on a non-empty line) and hitting F5 or Control + E.

OR, depending on why this is being requested, you can hide the "Results" and "Messages" tabs by hitting Control + R.

1

CTRL + R hides the display results grid.

1
  • It should be pointed out that this does not clear the results - if you type CTRL + R again it will show the results window with the previous results still available. Oct 23, 2020 at 20:37
0

just run a query that returns nothing

select 1 where 1 = 2
1
  • 3
    This returns a results panel that is empty. It does not clear the Results tab of prior result panels. More specifically, if I have: select 1; select 2; select 1 where 1 = 2; I will then see three panels on the results tab. That last select did not clear out the Results tab of the results of the first two queries. Apr 8, 2020 at 6:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.