Recently I got a task to upload heavy data to SQL server database. Data was in XML files and I am to upload that files in the database. Size of XML file was big. First I tried to fetch data and pull into my Data Base one by one. I faced performance issue due to continues inserting process. So decided to read XML file in the data table and upload this data table to SQL server database using SqlBulkCopy class. It was much better to copy data table to the database using bulk copy operation in c sharp.
The data table is being used to store SQL server data in memory for local use. So we can hold XML file data in Data table and bulk copy complete data of data table in the database with in seconds.