How to to not show visual results in GridView from the Queries

Andreas ss 726 Reputation points
2020-11-11T22:35:32.877+00:00

Hello,

  • sql server 2017 enterprise core
  • Visual Studio 2019 Preview

I am trying to do a benchmark to try out how long time different queries take. When running the quries, the results is shown in a Grid View, Text or as a file.
Below image shows that I put the results as Text which goes double as fast as the Grid View.

I wonder how to turn off so no results is displayed to only actually run the Query without showing any visually results in the GUI which then should make the benchmark results more correct?

Thank you!

DECLARE @t1 DATETIME;  
DECLARE @t2 DATETIME;  
  
SET @t1 = GETDATE();  
  
  
SELECT _FeatureNbr, _Value, _Bool  
FROM ForexForexEurusd15Min20113  
  
WHERE  
_DayNr = 15 AND  
_DateTime = '2011-03-15 01:15:00'  
  
SET @t2 = GETDATE();  
SELECT DATEDIFF(millisecond,@t1,@t2) AS elapsed_ms;  

39120-elapsed.png

SQL Server Other
0 comments No comments
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2020-11-11T22:49:19.923+00:00

    There is always overhead with returning the data. But my preference is to do

    SELECT * INTO #tmp FROM ....

    This does at least take out any network overhead out of the equation. Then again, there is overhead for writing to tempdb.

    If you to Tools->Options->Query Results, there is an option to discard query results, both for grid mode and text mode. I know some people who favour this option.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Jeffrey Williams 1,896 Reputation points
    2020-11-11T23:00:31.277+00:00

    You can also include client statistics - and that will show you a break down of time and network statistics. It will also calculate the average times for each execution as long as it is enabled.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.