All we need is an easy explanation of the problem, so here it is.
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
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
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.)
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂