12

I'm using Visual Studio 2008 and SQL Server 2008. I would like .sql files in my VS projects to open in SQL Management Studio by default. No problem so far: I right-click the file, Open With, Add SSMS, and set it as the default. What I don't like is that it opens a new instance of SSMS every time, and I would like it to open in an existing instance if there is one.

I noticed that the Open command associated with .sql files in Windows (which has the behavior I want) calls ssms.exe with the /dde switch. Not exactly sure what switch does, but I played around with it and it doesn't seem to have anything to do with opening files in an existing instance.

Any idea how I can get this behavior to work from within Visual Studio?

Thanks in advance!

3 Answers 3

25

Right click the .sql file within Visual Studio, then click "open with", then click "add..." in "Open with" dialog. In the "add program" dialog type "explorer.exe" into the program name field and somehting into "firendly name" field e.g. "with explorer", then click ok. Then select "with exlorer" in "Open with" dialog and click "set as default". Now VS will open .sql files with explorer wich will in its turn call SSMS.

Normally if you open 2 different .sql fiels in explorer you get them in a single SSMS window. If it still opens 2 ssms windows, you need to correct the registry (HKEY_CLASSES_ROOT\sqlwb.sql.9.0\Shell\Open\Command, replace /dde with %1)

Sign up to request clarification or add additional context in comments.

1 Comment

the core of your answer to this question works perfectly! The second thing you mention is happening to me so I tried to change "c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" /dde to "c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" "%1" %1 ... unfortunately I get errors and it still opens in separate windows.
0

Right - click on C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe file -> Properties -> Go to Compability Tab -> Uncheck all the checkbox.

Rerun SQL Management Tool.

Comments

0

I am using SQL Server Management Studio 2012 Express and I have made this to work by pointing "Program" to "explorer.exe"

This is how my register is set up: "C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" /dde

at

HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Open\Command

folder.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.