title: Connecting to a SQL Server in a network via Command Line and Windows Authentication
body: <p>From the system where the server is running, I can login using the following command:</p>
  
  <pre><code>sqlcmd -S "ComputerName\InstanceName" -d "DatabaseName" -i "sql.txt" -s"," -o "result.csv"
  </code></pre>
  
  <p>I want to connect to this server from another machine, So I tried this</p>
  
  <pre><code>sqlcmd -U "UserName" -S "ComputerName\InstanceName" -d "DatabaseName" -i "sql.txt" -s"," -o "result.csv"
  </code></pre>
  
  <p>"UserName" above is the default user name of the server machine that has administrative privileges. This user account does not have any password.</p>
  
  <p>After issuing that command, it asks for password. Since there is no password, I hit enter. But I get the following error:</p>
  
  <pre><code>Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login failed for user 'UserName'..
  </code></pre>
  
  <p><a href="http://msdn.microsoft.com/en-us/library/ms180944.aspx" rel="nofollow">SQLCMD Reference</a></p>