title: Windos Azure Mobile Service: Executing a Insert Stored Procedure in the data trigger
body: <p>I need to call a stored procedure when the Insert Script trigger is called.
  The idea is use the stored procedure to insert rows in 3 tables, including the original table.</p>
  
  <p>I have the following tables
  - cars
  - makers
  - models</p>
  
  <p>the stored procedure receives the car's data, maker's name and model's name. The SP looks in the makers and models table and insert a new record if not found.</p>
  
  <p>This is my script trigger code:</p>
  
  <pre><code>function insert(item, user, request) {     
  var params = [item.name, item.year, item.maker_name, item.model];
  var sql = "exec myCars.sp_insert_car ?, ?, ?, ?";
  mssql.query(sql, params,
  {
      success: function(results) {
          request.respond(statusCodes.OK,{ 
              results: results,
              count: 1
          });       
      }        
  });
  }
  </code></pre>
  
  <p>Because the sp_insert_car inserts a row in the cars table, the trigger is called again. The weird thing is that it is also called when a new maker or model is inserted.</p>
  
  <p>Is there a way to disable the second time the trigger is called?</p>
  
  <p>Also, the SP has an output parameter that returns the new car id. Is there a way to get this output parameter?</p>
  
  <p>I appreciate any help you can provide</p>