SQL Server Management Studio SQLCMD mode option
I recall in SQL Server 2005 Management Studio (SSMS) that I could quickly go into SQLCMD mode using a button on the SQL Editor toolbar. What happened to it in SSMS after SQL Server 2005, I can't find it?
I don't really know what Microsoft's reason for this was, but after SSMS 2005 the shortcut has been removed from the toolbar, by default. SQLCMD mode in SSMS allows you to use the command line tool within SSMS. If you are not familar with SQLCMD you can check out information on it here and here. You can enable SQLCMD mode permantenly through SSMS options or enable as you want to with the toolbar button, which is what I prefer to do.
This is the button I am referring to in SSMS 2005:
I have gone through a basic installation of SQL Server 2008, SQL Server 2008 R2, and even the CTP1 release of SQL Server 2012. All of the versions of SSMS that come with these editions do not have the SQLCMD mode button on the toolbar by default. So, in the remainder of this tip I am just going to provide a screen-by-screen walk through on how to add the button back to the toolbar. SQL Server 2008 and SQL Server 2008 R2 use the same method, but SQL Server 2012 interface for actually adding the button is a little different, so I will seperate that process. Although please note that 2012 I used is just a CPT1 release so it is subject to change by the time we get to the RTM release.
In all the Editions you will first need to open up the customize property window for the toolbars. The quickest way to get to this window is to just click on the Tools menu and select Customize. When that window opens you will click on the "Commands" tab. You will see this window in SQL Server 2008 and 2008 R2:
Click on "Query" in the left pane, and then go to the bottom of the right pane window. You should see SQLCMD Mode listed as this screenshot shows:
Simply left-click on SQLCMD Mode and drag it up to the toolbar. You should see the mouse pointer change when you begin to drag it and once you get it to the toolbar will see something similar to the screenshot below (within the red box that I drew around it). Once you place it where you want it just release it and it will stay in that position.
Now when you are in the SSMS version for SQL Server 2012 your Customize "Commands" toolbar window will look similar to this:
At this screen you will select the Toolbar radio button and then select "SQL Editor" in the drop-down menu:
Then to add the button to this toolbar click "Add Command" button. The next screen is similar to the previous steps where you select Query in the left pane, scroll to the bottom of right pane and select "SQLCMD Mode". Click OK to add it to the toolbar:
You can then click on the "Move Down" button to position the shortcut on the toolbar as you desire. As you click you should see the shortcut moving along the toolbar.
Last Updated: 2011-06-03
About the author
View all my tips