Tutorial :Is there a command line option like devenv.exe /Edit for Sql Server Management Studio



Question:

I'm using visual studio's external tools to open .sql scripts in Sql Server Management Studio (SSMS). The problem is, each time I use the external tools command to open a .sql file from visual studio, it opens a new instance of SSMS.

Visual Studio has a switch /Edit that will do this, is there one for SQL Server Management Studio?


Solution:1

Choose to open the file with Explorer[1] instead of SSMS. That way the system will search for any existing instances of SSMS first.

[1] %windir%\explorer.exe


Solution:2

I don't think the problem is with Visual Studio external tool command. Look at SSMS command line options - maybe there is a way to force reusing existing SSMS instance.


Solution:3

The following works for me ( I am SQL Server 2008 though) :

So the real answer I quess is to use cmdow

Edit: After more testing I realized the following : First open the files with connenction with: ( remove any enters while copying, this is one liner )

"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\  Common7\IDE\Ssms.exe" "C:\Users\yordgeor\Desktop\Trigger.sql"  "C:\Users\yordgeor\Desktop\Trigger1.sql" -S ysg -d poc_dev -E -nosplash   

In this example it opens two files ( but you could open less of course ; ) after which , No matter how many times I run

cmdow /Run "C:\Users\yordgeor\Desktop\Trigger1.sql"   cmdow /Run "C:\Users\yordgeor\Desktop\Trigger2.sql"   cmdow /Run "C:\Users\yordgeor\Desktop\Trigger3.sql"   

it opens the same instance of the Microsoft Sql Server Management Studio with the same connection

you could open at once at the command line many files , but I quess you asked for the upper answer.

So you could find the path to the Ssms.exe by: cd %ProgramFiles%

dir *ssms.exe /s /b

so the syntax of the command is: pathToTheExe pathToFile1 pathToFile2 -S serverName -d DatabaseToConnectTo -E (toUseWindowsAuthentication) -nosplash

After 20 seconds of googling I cheated from here:


Solution:4

The correct answer is no. The SSMS has a limited set of options, and although it uses the VS framework, does not support the edit command. This could be an interesting feature to add.

I am assuming you need to open these scripts in SSMS to be able to run them as well, otherwise I would suggest pointing them to Visual Studio directly since it does support syntax highlighting. However it will not solve your problem.


Solution:5

If you associate that file extension with Visual Studio, then VS should open it.

If you're finding that VS starts a new instance every time, then you need to specify the /edit command line option.

Take a look at http://stevedunns.blogspot.com/2009/03/programs-that-launch-or-should-launch.html for more information.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »