title: Insert into 2 tables simultaneously but stop if there are errors
body: <p>I have two tables in my SQL Server, Invoices and InvoiceDetails. 
  Invoices:</p>
  
  <pre><code>Invoice  |  Date         |  Total     | Salesman
  1001     |  10/10/2015   |  1000.00   |  101
  </code></pre>
  
  <p>InvoiceDetails:</p>
  
  <pre><code>ID  | Invoice          | ProductID  | Date       |Total   | Salesman
  1   |  1001            | 1          | 10/10/2015 | 200.00 | 101
  2   |  1001            | 2          | 10/10/2015 | 200.00 | 101
  3   |  1001            | 3          | 10/10/2015 | 100.00 | 101
  4   |  1001            | 4          | 10/10/2015 | 500.00 | 101
  </code></pre>
  
  <p>I would like to fill these two tables at the same time, meaning with just one sql query. I can use two insert statements as follows:</p>
  
  <pre><code>INSERT INTO InvoicesDetails(data) VALUES(data_to_insert)
  INSERT INTO Invoices(data) VALUES(data_to_insert)
  </code></pre>
  
  <p>I need to insert into the InvoicesDetails first before inserting it in the Invoices. But the problem is, what if the last transaction is not successfully recorded into the InvoiceDetails table? In theInvoices table, the particular Invoice, 1001, would have a total of 1,000.00 but in the InvoiceDetails, it will just be 500.00 since it was not successful in inserting the last transaction of 500.00.</p>
  
  <p>How do I implement inserts in one sql syntax on this situation?
  Thank you!</p>