Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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).

like image 230
sheldonhull Avatar asked Jan 28 '13 14:01

sheldonhull


People also ask

How do I run a SQL script in SQL Server 2012 Management Studio?

Click Query > Connection > Connect to connect to the server that contains the database you want to access. Select the appropriate StarTeam Server database. Open the tuning script, by choosing File > Open > foldername\scriptname. Execute the script, by clicking the Execute button on the toolbar or by pressing F5.

How do I open SQL File in SQL Server Management Studio?

You can open a document in one or more editors by clicking Open on the File menu and then clicking File. In the Open File dialog box, select the file, click the Open arrow, and then click Open With. In the Open With dialog box, in the Select a program to open list, click the preferred program, and then click Open.

How do I import a .SQL File into SQL Server 2012?

In SQL Server Management Studio, enter details, click Connect, right-click the database, and click Import Data.


1 Answers

  1. To change to default entry I utilized an application that displayed the DDE (dynamic data exchange) values. I personally used FileTypesMan.
  2. I then changed the command line for SSMS to:

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

    The reason a new instance is always opened with editing seems to be that windows needs to associate the file with a program so that it can identity if the existing program is running and use this instance. This seems to be achieved by using DDE. /dde indicates that the command line should use DDE. "%1" passes the first string (ssms.exe path) to the DDE protocol for usage as a parameter.

  3. DDE Message: was kept at the SSMS 2008 R2's value I found: Open("%1")

  4. DDE Application: Change the Application to ssms.11.0

    Why? This was the difficult part. Where is this found? I could not find a tool for displaying the DDE application name. What I found was when I reviewed the registry editor that sqlwb.sql.9.0 is the entry to open a new .sql file with 2008 R2. This matched the registry entry for sqlwb.9.0 that SSMS 2008 R2 entry was showing before I started making my changes in FileTypesMan. I removed the .sql and found that the HKEY_CLASSES_ROOT had an entry for ssms.sql.11.0 .

= File association now set to new installation, and if SSMS.EXE is open, it should use the existing instance with no additional work.

Tip: To further speed up the initial load if you don't have it open, you can use other command line options on the load. Just go to the RUN dialog and type: ssms.exe -? for a list of startup parameters. I personally use -nosplash to eliminate the splash screen load.

Additionally, I use SSMSBoost, the single greatest tool I've had to help with using SSMS daily (basic code formatting, snippet w/cursor placement, preferred connections setup, full keyboard shortcut programming (along with the option for multiple steps in once shortcut, ie basic macros". Andre and his team are extremely responsive to new ideas in their forum, its very much developers helping improve other developer's life.

like image 157
2 revs, 2 users 80% Avatar answered Oct 16 '22 14:10

2 revs, 2 users 80%