title: How to bulk insert data into SQL Server using node.js
body: <p>I want to insert 100k rows into a SQL Server database using node. I have tried it using bulk method of request object but it will not working for me.</p>
  
  <p>My function to insert into SQL Server database:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var startInsert = function(recordset) {
  
      sql.connect(config,function(err) {
       // console.log(recordset);
       if(err){
           console.log(err);
         }
           
          var table = new sql.Table('ShipmentAuditLogTest');
  
        recordset.forEach(function(row) {
              table.rows.add(row.ShippingID,row.BagNo,row.ProcessLocation,row.Process,row.Comment,row.CreatedDate,row.CreatedBy,row.LastModifiedDate,row.LastModifiedBy,row.DestinationLocation,row.VenderLostShipmentsDebitId);
           
        });
  
        var request = new sql.Request();
  
     request.bulk(table, function(err, rowCount) {
     console.log(table);
  
           if(err)
            console.log(err);
           console.log(rowCount);
        });
      });
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>This will return this error:</p>
  
  <blockquote>
    <p>{ [RequestError: Incorrect syntax near ')'.]<br>
    name: 'RequestError',<br>
    message: 'Incorrect syntax near \')\'.',<br>
    code: 'EREQUEST',<br>
    number: 102,<br>
    lineNumber: 1,<br>
    state: 1,<br>
    class: 15,<br>
    serverName: 'FCCHAKANDB',<br>
    procName: '',<br>
    precedingErrors: [] }</p>
  </blockquote>
  
  <p>My recordset:</p>
  
  <pre><code>[ RowDataPacket {
      ShippingID: '2FX880141',
      BagNo: 'CHKXFL1808362',
      ProcessLocation: '2',
      Process: 'BagIn',
      Comment: 'Shipment added in ParentBagNo: CHKXFL1808362',
      CreatedDate: Tue Apr 07 2015 16:36:18 GMT+0530 (India Standard Time),
      CreatedBy: 'support@firstcry.com',
      LastModifiedDate: '0000-00-00 00:00:00',
      LastModifiedBy: 'null',
      DestinationLocation: 'null',
      VenderLostShipmentsDebitId: 0,
      InsertedTime: Mon Dec 14 2015 14:26:16 GMT+0530 (India Standard Time) } ]
  </code></pre>