Login to SQL Server from command line
The correct syntax for Connecting to a default instance by using Windows Authentication to interactively run Transact-SQL statements

sqlcmd -S &lt;ComputerName&gt;  


Connecting to a named instance by using Windows Authentication to interactively run Transact-SQL statements:

sqlcmd -S &lt;ComputerName&gt;\&lt;InstanceName&gt;  


Connecting to a named instance by using Windows Authentication and specifying input and output files:

sqlcmd -S &lt;ComputerName&gt;\&lt;InstanceName&gt; -i &lt;MyScript.sql&gt; -o &lt;MyOutput.rpt&gt;  


Connecting to the default instance on the local computer by using Windows Authentication, executing a query, and having sqlcmd remain running after the query has finished running:

sqlcmd -q "SELECT * FROM AdventureWorks2012.Person.Person"