Go get me a switch!


You probably access SQL Server Management Studio (SSMS) using an icon somewhere in your Start menu or on your desktop. But did you know that there are several command-line switches that you can use to start SSMS and end up right where you want to go?


Drop to a command-prompt and type this:


Sqlwb /?


If the tools are in the system’s path variable, you’ll get a pop-up dialog explaining all of the options. Here they are, in case you’re reading this on a bus (like where I’m writing it!) – Note that case matters:


-S ServerName
This is the name of the server instance you want to connect to. If you don’t put anything here you’ll start up in a disconnected window, which can be useful if you just want to edit some scripts.


-d  DatabaseName
This is the name of the database you want to connect to on the instance. If you don’t put anything here you will be dropped at the server itself.


-E
This implies a trusted connection, so you don’t have to type a name and password if you’re using a Windows account to log in to SQL Server.


-U UserName
If you don’t use -E, this switch sets the user name for SQL Server authentication. Again, case counts here for the switch, not for the user name, unless your system is using a case-sensitive arrangement.


-P PassWord
This switch sets the password. If you use –U, you have to use –P as well.


filename
This is really cool – you can pass a filename to be opened when you start, such as a T-SQL script you want to edit or run. Note that there is no – here, just the path and name of the file.


-nosplash
Don’t like the splash screen that comes up when SSMS opens? Turn it off with this switch.


/?
This switch just shows the options.

Comments (2)

  1. sundanceca says:

    How ’bout running it via your other windows ID?  We have special server/dba type windows login, different then the id with which we’re logged on to our laptops..Other then doing a ‘run as’, how can I switch my way to using another windows id?

  2. BuckWoody says:

    Good question – and one we get asked often. The easiest answer is "Run As" and then enter your credentials there.