Command-line options connecting SQL server

My collegue and I were searching for a handy solution to login with a different account then the login-account for the server. We find the following solution:

image

But this can be automated using the command-line options. If you like to see the list of available command-line options, go to Start > Run > type “SSMS /?”:

This will display the all available options which can be used with SSMS,

image

The options are self-explanatory, the -E is used for Windows Authentication. – U, – S are used for SQL Server Authentication Both should be mutually exclusive. if you used together the SQL Server Authentication will take precedence. for example, to connect to default instance of local SQL Server execute below from Start > Run or from CMD.

 SSMS S(local) –E
– connect to default instance using Windows Authentication

 

SSMS S(local)\InstanceName –E
– connect to named instance using Windows Authentication

 

SSMS S(local) U sa P P@$$w0rD
– connect to default instance using SQL Server Authentication

 

SSMS S(local) E U sa P P@$$w0rD
– connect to default instance using SQL Server Authentication
– SQL Server Authentication takes precedence

 SSMS S(local) E C:\MyQuery.sql
– connect to default instance using Windows Authentication
– and open a saved query file

 SSMS S(local) d AdventureWorks2008R2 E
– connect to default instance using Windows Authentication
– and change context to AdventureWorks2008R2 database

 All the options described above are for SQL Server 2008. The same options can be used with SQL Server 2005. However, for SQL Server 2005, replace SSMS.exe with SqlWb.exe.

This article was written down by Vishal

Geef een reactie

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie gegevens worden verwerkt.