Scenario: On double-clicking a .sql file on a computer with SQL Server Management Studio 2008 (SSMS) or SSMS 2008 R2 installed, the SSMS window opens, but without the .sql file loaded.

Solution: the problem is in the registry.  The Open key isn’t passing the “%1” parameter.  Just modify the command to add the parameter. 

Here’s how:

1. Find the reg key for .sql files

Get the Data value for the (Default) for the .sql key in this registry path: HKLM_CLASSES_ROOT\.sql

image

In this example, the (Default) value for me was sqlwb.sql.9.0

2. Go to the registry key you identified in step 1

To get to this key quickly, I just start typing “sqlwb.sql” which jumps my cursor down to that node.

Expand that node, then expand Shell, then expand Open, then expand Command:

image

Note that the command was:

"c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde

And that this command is missing the “%1” file parameter.  Modify the command to include the “%1” parameter like this:

"c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde

(Note: just add the “%1” part (with straight quotes, not curly quotes) to the path before the /dde part – don’t copy my path from this note or you could break it if my path happens to be different than yours).

After editing the key looks like this:image

Done

Once you’ve changed that setting the next time you double-click a .sql file SSMS should open with the file open.

Advertisements