I am running SQL Server Management Studio 2005 on a Windows 7 machine here at work. I am not sure when this started happening, but when I double-click a .sql file in Explorer, SQL Server Management Studio (SSMS) would open, but would not load the file in question. It would also not bring up a logon screen to connect to an instance. I tried unassociating the .SQL extension and then re-associating it using "Open With" SQL Server Management Studio, but it never worked. I made suggested registry modifications; uninstalled and reinstalled SSMS, but nothing would resolve the issue. Then "duh"....I looked at the SSMS Tools menu. To my surprise, the "File Extension" window was empty!
Surprisingly, I haven't been able to find this solution ANYWHERE, even in Microsoft SQL Help Solutions. Microsoft, and almost every other site, refers to modifying the "HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command" to fix this issue. Even after uninstalling/installing SSMS, I was never able to find this Registry Key.
I hope this solution helps, and here is what I did.
- Open SQL Server Management Studio
- Select Tools > Options
- Expand Text Editor > Select File Extension
- Type "sql" in the "Extension" box
- Select "Editor" Drop-Down and choose "SQL Query Editor"
- Click "Apply" and "OK"
- Repeat Steps 1-6 to allow "txt" files to open in SSMS (by Right-Clicking on Text File and selecting "Open With "SQL Server Management Studio"
Now close SSMS and double-click on a .sql file. Your script should now open in SSMS Query Window.