Inhibiting results to pane in SSMS (TSQL language) via script

The question:

I found that one could use a menu to “discard” results in SSMS (TSQL language). Please see: Original Question about inhibiting results and its answer.

However, I was wondering if there is a script command that will do this, as sometimes I forget to run the command using the windows menu option.

I am using SSMS 18.8 to run the query, the actual db is older still.

PURPOSE: In this case, I am running several trials of queries to optimize them. See also: Useful optimization link

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

As far as I know, there isn’t, because this is a feature of SSMS itself to not render the results to a UI Grid object, not a function of the T-SQL language.

That being said, you can emulate a similar outcome by selecting your results to a local #TempTable and then dropping that table right after. Then the SSMS Elapsed Time will match the actual query Execution Time, most times. (It isn’t a perfect alternative, if your server faces a lot of tempdb contention, but usually that’s not the case.)

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment