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

sheldonhull picture sheldonhull · Jan 28, 2013 · Viewed 22.9k times · Source

Installation of SSMS 2012 alongside any other existing SSMS installation, such as SSMS 2008 R2 has a problem with setting the default program for opening .SQL files to the new SSMS 2012 version.

Dragging .sql file to the query window works successfully. However, when a user double clicks on the .sql file a new instance of 2008 R2 can open as the .sql associated entry. Changing with Default Open With makes no difference when doubleclicking on new files. Additionally, altering the command line script for the opening can perhaps achieve changing the .sql to opening in SSMS 2012, but it still causes repeated instances of ssms instead of using the existing instance (causing additional load and memory usage).

Answer

KyleMit picture KyleMit · Mar 20, 2015
  1. Adapted from this post on how to how to fix .sql file not opening with SSMS 2008, you should start by opening up the registry (regedit)
  2. Go to HKEY_CLASSES_ROOT\.sql and change the default value to ssms.sql.11.0 (SSMS 2012 is v11 of the product). This tells your computer the application string it should look for when trying to open files of type .sql

    .sql

  3. The registry takes that name you just entered and then looks up what to actually go do in another registry setting.

    Go 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

  4. Turn your computer off and on again for good measure.

    If it still doesn't work for whatever reason. Right click on any SQL file. Go to Properties and click to change the file it opens with. You may have two SQL options available. Try one then the other.

    open with