title: How to connect to SQL Server with windows authentication from Node.JS using mssql module
body: <p>Hi I'm unable to connect to SQL server that is using windows authentication in node js. I'm using the mssql module. The error message is :</p>
  
  <pre><code>[ConnectionError: Login failed for user ''. The user is not associated with a trusted SQL Server connection.]
  name: 'ConnectionError',
  message: 'Login failed for user \'\'. The user is not associated with a trusted SQL Server connection.',
  code: 'ELOGIN' }
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>config = {
      server : "localhost\\MSSQLSERVER",
      database : "mydatabase",
      port : 1433
  }
  
  function loadDepts() {
      var conn = new sql.Connection(config);
      var request = sql.Request(conn);
  
      conn.connect(function(err) {
      if (err) {
          console.log(err);
          return;
      }
  
      request.query("select deptid, deptname from departments", function(err, table) {
          if (err) {
             console.log(err);
             return;
          }
          else {
             console.log(table);
          }
  
          conn.close();
          });
      });
  }
  
  loadDepts();
  </code></pre>