title: Database connection fails when connecting using sqlcmd with encrypt connection
body: <p>I am trying to connect to sql server with forced encryption using sqlcmd.</p>
  
  <p>I have added a certificate to sql server and enabled forced encryption.</p>
  
  <p>But the sqlcmd tool is not able to connect to the sql server. Below is the command I am using:</p>
  
  <pre><code>sqlcmd -S"mymachine.mydomain.dom" -b -d"mydatabase" -i"E:\mysqlfile.sql" 
  -v mode="Load"  -N -U"sa" -P"password"
  </code></pre>
  
  <p>this works when I remove mydomain.dom and -N option like:</p>
  
  <pre><code>sqlcmd -S"mymachine" -b -d"mydatabase" -i"E:\mysqlfile.sql" 
  -v mode="Load" -U"sa" -P"password"
  </code></pre>
  
  <p>What may be the reason?</p>
  
  <p>Edit : I have stored the server certificate in both personal and trusted people store. I also ran the follwing query to check the encryption .</p>
  
  <pre><code>SELECT encrypt_option FROM sys.dm_exec_connections
  </code></pre>
  
  <p>encrypt_option is true for all the sessins.</p>
  
  <p>Edit 2 : I am using a default instance. The certificate CN is mymachine.mydomain.dom. Also another connection to the same database with encrypt=true and using .net code is working fine. So this doesn't seems to be a certificate issue.</p>
  
  <p>Edit 3 : Tcp/ip is enabled in network configuration. Remote connection is also enabled. I also tried executing sqlcmd as administrator but got the same error.</p>