Results to Grid

What is Results to Grid and what can it do for you?  Results to Grid are Query Results options in SQL Server Management Studio (SSMS) that can help users customize their query results in a variety of ways that can help make users more efficient.  Some of these might be little changes, but when used often throughout the day, they can make a big difference.  Once you change the setting, you will need to open a new query window for the change to go into effect.  These changes can be made at:

Tools > Options > Query Results > Results to Grid

ResultsToGrid

 

Include Query in the Result Set

The default for Include Query in the Result Set is off.  When toggled on, the query is included in the messages tab of the results.

QueryInResult

Include Column Headers When Copying or Saving the Results

The default for Include Column Headers When Copying or Saving the Results is off.  When it is toggled on, the column headers are copied or saved with the output.  To copy the results, you would highlight the upper left corner of the result set and right click.  You can select Copy or Copy with Headers.  (You can also use CTRL+C (copy) or CTRL+SHIFT+C (copy with headers).)  Either way, the column headers will be copied along with the data.

When you save the query results (Save Results As…), there is not an option to include headers from the menu.  To include columns headers when saving data, this feature must be toggled on and it must be turned on prior to running the query for the Column Headers to be included in the output.

ColumnWhileCopying

 

Retain CR/LF on Copy or Save

When copying information into Notepad, the carriage return and line feeds from the text are not always carried over.  In the example below, I will show the difference in the results when this option is toggled on and off.

Note the two queries.  They are slightly different to make it easier to identify the results.  The query on the left has the Retain CR/LF on Copy or Save toggled on, the one on the right has the feature toggled off.  Looking at the results of each query, they are the same in the Results tab.  The difference occurs when you copy the data into another format, such as Notepad.

CR_LF

Discard Results After Execution

Really…discard the results after execution of a query.  Isn’t the point of running the query to get the results of the query?  Not always.  Suppose you need the results of the execution plan and not necessarily that of the data.  That would be one situation where you would not care about the result set.  By toggling on this option, you will save on memory but not CPU or IO.  If you are working with a large data set, this could also save you time as you do not have to wait for the dataset to load before getting the execution plan.  This is primarily a tool to use for troubleshooting.

DiscardResults

Display Results in a Separate Tab

The default setting in Query Editor is with Editor pane at the top and the Results and Messages pane at the bottom of the window.  Users can also set up the Results and Messages panes to appear at the top of the query window, allowing more space for results.  With the results in a separate tab, the tabs are on the same horizontal plane and it is easier to switch from the Editor to the Results to the Messages because they are all together.  To make this change, go to the following and toggle on ‘Display Results in a separate tab’.

The images below show the default Results pane at the bottom of the Query Window (Left) and with the results in a separate tab (Right).

SeparateTab

 

There is a setting under the Display Results in which you can toggle on: ‘Switch to the results tab after the query executes’.  With the display panes in separate, horizontal tabs, you can’t see the results after running a query like in the default format without switching to the Results pane.  This feature will save you that step of running the query then tabbing to the Results pane.  The Results tab will automatically open when executing the query.  The two options really go hand-in-hand.

 

1 thought on “Results to Grid

  1. Pingback: SSMS Grid Options – Curated SQL

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s