Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Management Studio won't open scripts on double-click

I'm used to double-clicking *.sql script files to open them in SQL Server Management Studio. I recently upgraded to Win7, and now when I double-click a script file, SSMS opens with an empty environment. I can then use File/Open or File/Recent Files to open my script, but I would much prefer for it to just open whatever I double-clicked on like a normal application would.

Any ideas what's going on?

BTW when I double-click a script from the Solution Explorer in Visual Studio, it does open it automatically just like you would expect.

like image 692
Herb Caudill Avatar asked Nov 13 '09 01:11

Herb Caudill


People also ask

How do I open a script in SQL Server Management Studio?

Open SQL Server Management Studio > File > Open > File > Choose your . sql file (the one that contains your script) > Press Open > the file will be opened within SQL Server Management Studio, Now all what you need to do is to press Execute button.


2 Answers

I had the same problem. I don't know what caused it, but I fixed it with a quick Registry hack.

  1. Go to HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command
  2. Edit the (Default) value
  3. It should contain something like this: "c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde
  4. Add "%1" to the end
  5. The final value will be something like this: "c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde "%1"
like image 78
Josh Yeager Avatar answered Oct 18 '22 22:10

Josh Yeager


In my case the registry key that needed fixing was HKEY_CLASSES_ROOT\.sql

The (Default) had been changed to sql_auto_file... and needed to be ssms.sql.12.0 (for SSMS 2014)... presumably ssms.sql.11.0 for SSMS 2012.

All the other stuff down in the HKEY_CLASSES_ROOT\ssms.sql.12.0 path, that most other solutions tend to refer to, was fine as is.

screenshot of proper reg entry

like image 9
Beej Avatar answered Oct 18 '22 22:10

Beej