DDE is used to allow the shell to open multiple .SQL files in the same instance. You need to modify the registry to get that to work.
NOTE: The shell associations are stored under HKCR
however you can override the global settings on a per-user basis. These are stored under HKCU\Classes
. Ensure you don't have an overridden version when making changes to the registry as that will cause the global settings to be ignored.
- Open Regedit.
- The shell first looks up the file extension in the registry to get the file type. This allows multiple file extensions to map to the same commands. NOTE: You would need to do this for each file extension you want to adjust the behavior of. Go to
HKCR\.sql
. - The default value of this key is the file type. For my machine it is
ssms.15.0
. - Go to the file type key under
HKCR
. This is where the shell gets the commands for the context menu. They reside under theshell
key. You may see one or more verbs such asedit
andopen
. You'll want to adjust the command for the default verb the shell uses. - Go to the
command
key. This is the command that the shell runs when you select the verb. The key here is that it must use DDE. On my machine it looks like this:"<path>\ssms.exe" /dde
. The double quotes are critical to allow for long file names. - For DDE the shell then needs to know how to start up the DDE server. For that it goes to the
ddeExec
key. - This key has a default value that specifies the DDE command to use. For SQL it is
Open("%1")
. This tells SSMS to open the given file, again the double quotes are critical. Given that DDE command the current SSMS instance will open the given file in the existing instance.
I'm attaching the .reg file that is used on my machine that causes SSMS to open SQL files in the same instance for your reference.