I have a DataTable in memory that I need to dump directly into the temp table of SQL Server.
After the data has been inserted, I will transform it a bit, and then paste a subset of these records into a persistent table.
The most time-consuming part of this operation is getting the data in the temp table.
Now I have to use temporary tables, because several copies of this application are launched immediately, and I need an isolation layer until the actual insertion into the constant table occurs.
What is the fastest way to do bulk insert from C # DataTable to SQL Temp table?
I can not use third-party tools for this, as I convert data to memory.
My current method is to create a parameterized SqlCommand:
INSERT INTO
and then for each line, clear and set the parameters and execute.
There should be a more efficient way. I can read and write to disk in seconds ...
John gietzen
source share