SQL SERVER – SSMS Trick – Switching Columns in Grid Output

Yesterday when I wrote about what I learnt from Vinod’s session at the SQL Server User Group meeting, one of my friends wrote back asking what else was discussed. Though I knew some of the tips and tricks he showed as part of the sessions, there were few that stuck in my mind. His session around security and how some of the fundamentals were shaken was worth every minute. In this blog we will discuss about how we can switch column in grid output.

Anyways, coming back to some of the other tips that were shared. This is not as simple as it seems. In a matter of fact, I hadn’t even tried it before, but was surprised that it was still possible. One of the questions asked as part of the UG meet is the ability to reorder your output shown in SQL Server Management Studio. In this case, I felt we need to just change how the query is written and it will be taken care. But was I proved to be wrong.

In SQL Server Management Studio, in the grid view, you can move around the output pane window. I am showing you a typical example below where I moved the “ModifiedDate” column on top of the “GroupName” column. See the red bar that comes up when the columns are moved.

Solarwinds

SQL SERVER - SSMS Trick - Switching Columns in Grid Output switch-columns-01

Interesting, isn’t it? I have not personally changed the query to get the output, but have played around with the view in Grid to get what I wanted. As you can see the columns have been swapped.

SQL SERVER - SSMS Trick - Switching Columns in Grid Output switch-columns-02

Do you any other trick in the Grid view that is worth a share? Do let me know via comments below on the tricks you have been showing your friends at work that got them a “Wow”? Will you be using this trick any time? Let me know your thoughts.

NOTE: I know I can easily re-write the query and change the order of the result set. However, this blog post is about SSMS trick which exists and can be used when you can’t change the order of columns in the query.

Reference: Pinal Dave (https://blog.sqlauthority.com)

Solarwinds
,
Previous Post
SQL SERVER – Hidden SSMS Gem: Find Dialog’s Unknown Functionality
Next Post
SQL SERVER – Simple Example of BCP Command Line Utility

Related Posts

4 Comments. Leave new

Leave a Reply

Menu