I use C# SqlBulkCopy
class to load big XML file to SQL server. I've implemented IDataReader
, which loops throught XML and get values.
The file contains a lot of tables, so I have to call SqlBulkCopy
. WriteToServer method as many times as many tables I have in source XML file. Every time DataReader loops throught whole file, which takes a lot of time.
How can I improve perfomance of my app? Is there a better way to do what I want?
Here is a plan of my program:
- Loop thru source file - determine tables and their columns (and datatypes).
- Create tables on Sql Server.
- Load data to Sql Server by looping source file and get the values for each table I've determined, one by one.