title: Inserting/updating huge amount of rows into SQL Server with C#
body: <p>I have to parse a big XML file and import (insert/update) its data into various tables with foreign key constraints. </p>
  
  <p>So my first thought was: I create a list of SQL insert/update statements and execute them all at once by using <code>SqlCommand.ExecuteNonQuery()</code>.</p>
  
  <p>Another method I found was shown by AMissico: <a href="https://stackoverflow.com/questions/2972974/how-should-i-multiple-insert-multiple-records">Method</a>
  where I would execute the sql commands one by one. No one complained, so I think its also a viable practice.</p>
  
  <p>Then I found out about <code>SqlBulkCopy</code>, but it seems that I would have to create a DataTable with the data I want to upload. So, <code>SqlBulkCopy</code> for every table. For this I could create a DataSet.</p>
  
  <p>I think every option supports <code>SqlTransaction</code>. It's approximately 100 - 20000 records per table.</p>
  
  <p>Which option would you prefer and why?</p>