title: SQL Server : Delete the record in table based on the value of TVP table
body: <p>I have a <strong>PurchaseStationeryDetails</strong> and <strong>TVP(Table valued parameter) TVP_PurchaseStationeryDetails</strong>, My question is-->I wanted to <strong>delete</strong> the record from <strong>PurchaseStationeryDetails</strong> that are not avaliable in <strong>TVP table</strong>. <a href="https://i.stack.imgur.com/ZNfDf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZNfDf.png" alt="enter image description here"></a></p>
  
  <pre><code>declare @TVP_PurchaseStationeryDetails as TVP_PurchaseStationeryDetails
  </code></pre>
  
  <p>Just Consider that i inserted data into <strong>TVP table</strong></p>
  
  <pre><code>DELETE  from PurchaseStationeryDetails
              WHERE PurchaseStationeryMasterId = 1003 AND  PurchaseStationeryDetailsId  IN
                      (SELECT PSD.PurchaseStationeryDetailsId FROM PurchaseStationeryDetails PSD, @TVP_PurchaseStationeryDetails TVP_PSD 
                             WHERE PSD.PurchaseStationeryMasterId = TVP_PSD.PurchaseStationeryMasterId AND PSD.PurchaseStationeryDetailsId  ! = TVP_PSD.PurchaseStationeryDetailsId AND TVP_PSD.PurchaseStationeryDetailsId != 0)
  </code></pre>
  
  <p><strong>Columns</strong> in <strong>PurchaseStationeryDetails</strong>--->PurchaseStationeryDetailsId, PurchaseStationeryMasterId.....etc</p>
  
  <p><strong>Columns</strong> in <strong>TVP_PurchaseStationeryDetails</strong>--->PurchaseStationeryDetailsId, PurchaseStationeryMasterId.....etc</p>
  
  <p>Here i wanted to delete the record -> <strong>104,2</strong> from PurchaseStationeryDetails table</p>