title: Unable to connect to SQL Server using SQLCMD via a batch file
body: <p>I'm scheduling a task in Windows to connect to an off-site SQL Server every night to run a query and save the results as a .CSV file.  I'm able to connect to the SQL Server using SSMS with no problems at all.  I'm able to connect to the SQL Server manually using SQLCMD from a command prompt with no problems at all.  My issue is I cannot use SQLCMD within a batch file.  The syntax I'm using is......</p>
  
  <p>sqlcmd -S ServerName\InstanceName -d DatabaseName -U UserName -P Password </p>
  
  <p>If I manually enter that into my command window, it works like a champ.</p>
  
  <p>If I try to connect using a batch file, I get the error, "Msg 18456, State 1, Server ServerName\InstanceName, Line 1 Login failed for user 'UserName'.</p>
  
  <p>I've also tried right clicking the batch file and running as administrator with no success.  Thank you in advance for your help.</p>
  
  <p>Travis</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I just now discovered that if you take the -P Password parameter out of the batch file, you will be prompted for the password.  After entering my password, I'm logged in successfully.  Are there limitations on passing passwords to the SQL server from a batch file?  Being that this is an off-site server that's not on our network, I'm unable to use Windows Authentication.  </p>