title: Passing an array of objects to SQL stored procedure
body: <p>I have 2 tables </p>
  
  <ul>
  <li><code>payment</code> (<strong>payment_id</strong>, otherCosts, GarageCosts)</li>
  <li><code>spareparts</code> (payment_id, sparepartId, sparePartQty)</li>
  </ul>
  
  <p>In <code>payment</code> table <code>payment_id</code> is autogenerated. Apart from <code>otherCosts</code> and <code>garagecosts</code> values, in my C# asp.net application there is an array of objects with </p>
  
  <pre><code>{ sparepartId : 'Somevalue', sparePartQty : 'somevalue' }
  </code></pre>
  
  <p>What I need to do is in a stored procedure first enter the record into payment table with garage costs and others costs value. Then return the last generated payment ID and enter it to <code>spareParts</code> table as <code>paymentId</code> for each of the value pairs in the array.</p>
  
  <p>What is the way to achieve this? Please help.</p>