Opening .sql files in SSMS 2012 as the default program and with an existing instance

Installing SSMS 2012 along with any other existing SSMS installation, such as SSMS 2008 R2, has a problem installing the default program to open .SQL files for the new version of SSMS 2012.

Dragging and dropping the .sql file to the query window works successfully. However, when the user double-clicks the .sql file, a new instance of 2008 R2 may open as a .sql-related entry. Changing with the Open By Default function Does not matter when you double-click on new files. Also, changing the command line script to open may possibly change the .sql to open in SSMS 2012, but it still causes repeated ssms instances instead of using the existing instance (which causes extra load and memory usage).

+8
sql-server ssms-2012
source share
6 answers
  • To change the default entry, I used an application that displays the values โ€‹โ€‹of DDE (Dynamic Data Exchange). I personally used FileTypesMan .
  • Then I changed the command line for SSMS to:

    "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe" /dde "%1" 

    The reason that a new instance always opens with editing, it seems that windows require a file to be associated with the program so that it can identify if an existing program is running and using that instance. This is apparently achieved using DDE. /dde indicates that DDE should be used on the command line. "% 1" passes the first line (ssms.exe path) to the DDE protocol for use as a parameter.

  • DDE message: stored in the SSMS 2008 R2 value that I found: Open("%1")

  • DDE application: change the application to ssms.11.0

    Why ? That was the hard part. Where is it found? I could not find a tool to display the name of the DDE application. I found that when I looked at the registry editor, sqlwb.sql.9.0 is the entry for opening a new .sql file from 2008 R2. This corresponded to the registry entry for sqlwb.9.0 that the SSMS 2008 R2 record showed before I started making changes to FileTypesMan. I deleted .sql and found that HKEY_CLASSES_ROOT has an entry for ssms.sql.11.0 .

= Now the file association is installed on a new installation, and if SSMS.EXE is open, it should use the existing instance without additional work.

Tip . To speed up the boot, if you do not have one, you can use other command line options at boot time. Just go to the RUN dialog and type: ssms.exe -? list of launch options. I personally use -nosplash to prevent the screensaver from loading.

In addition, I use SSMSBoost , the largest tool with which I had to use SSMS daily (basic code encoding, fragment with cursor placement, setting preferred connections, full programming on the keyboard (along with the possibility of several steps at once with a shortcut, i.e. with basic macros.) Andre and his team are very sensitive to new ideas in their forum, another life of the developer.

+10
source share
  • Adapted from this post on how to fix a .sql file that does not open using SSMS 2008 , you should start by opening the registry ( regedit )
  • Go to HKEY_CLASSES_ROOT\.sql and change the default value to ssms.sql.11.0 (SSMS 2012 - v11 product). This tells the computer the application string that it should look for when trying to open .sql files

    .sql

  • The registry accepts the name you just entered and then looks at what to actually do in another registry setting.

    Go to HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Command and change the default value to:

     "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" "%1" /dde 

    ssms.sql.11.0

  • Turn the computer off and on again.

    If it still does not work for some reason. Right click on any SQL file. Go to the "Properties" section and click to modify the file that opens. Perhaps you have two options for SQL. Try one another.

    open with

+14
source share

For SQL 2014, you can use the following * .reg file (in 2012 replace 12 with 11 and in 2016 (I think) with 13):

 Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\sql_auto_file] @="" "EditFlags"=hex:00,00,00,00 "FriendlyTypeName"="SQL" [HKEY_CLASSES_ROOT\sql_auto_file\shell] [HKEY_CLASSES_ROOT\sql_auto_file\shell\open] [HKEY_CLASSES_ROOT\sql_auto_file\shell\open\command] @="\"C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\ManagementStudio\\Ssms.exe\" /dde \"%1\"" [HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec] @="Open(\"%1\")" [HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec\Application] @="ssms.12.0" [HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec\Topic] @="system" 
+2
source share

I had the same problem. Using "restore file associations" in ssms 2012 did not affect. I was able to resolve it by right-clicking and choosing "open with" โ†’ select the default program. Now I know that you said that it did not work, but there is a trick. Instead of choosing the preinstalled icon for ssms 2012, select View and browse to c: \ program files (x86) \ Microsoft SQL server \ 110 \ tools \ binn \ managementStudio \ and click ssms.exe. Click "Open", click "OK." As soon as I did this, ssms 2012 was by default, and double-clicking on the .sql files downloads to the tabs in the same instance.

+1
source share

Another solution: stack overflow

I went looking for a more suitable way to contact another Q / A and could not find it after 15 minutes of searching ... I would like to get an education and edit it, if so.

0
source share

I had a similar but slightly different problem. I wanted to open the .sqlplan file in a new tab in SSMS 2014. I tried all of the above, but none of them worked.

Looking at the registry, I found that ssms.sql.12.0 has a "DdeExec" node, and ssms.sqlplan.12.0 does not.

enter image description here

So, I export the "DdeExec" node from ssms.sql.12.0 and rename sql to sqlplan and then import it back. After that, I was able to open the .sqlplan file in a new tab.

Here is the registry file: Windows Registry Editor version 5.00

 [HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec] @="Open(\"%1\")" [HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec\Application] @="ssms.12.0" [HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec\Topic] @="system" 
0
source share

All Articles