I have a Qt application, that reads a special text file, parses it and inserts about 100000 rows into a temporary table in a firebird database. Then it starts a stored procedure to process this temporary table and apply some changes to permanent tables. Inserting 100000 rows into in-memory temporary table takes about 8 seconds on firebird.
Now I need to implement such behavior using MS SQL Server 2008. If I use simple serial inserts it takes about 76 seconds for 100000 rows. Unfortunately, it’s too slow. I looked at the following ways:
- Temporary tables (# and ##). Stored on the disk in tempdb scheme. So there is no speed increase.
- Bulk Insert. Very nice insertion speed, but thre is a need to have client or server-side shared folder.
- Table variables. MSDN says: “Do not use table variables to store large amounts of data (more than 100 rows).”
So, tell me please, what is the right way to increse insertion speed from client application to MSSSQL2008.
Thank you.
You can use the bulk copy operations available through OLE DB or ODBC interfaces.
This MSDN article seems to hold your hand through the process, for ODBC:
If you need a cross platform implementation of the bulk copy functions, take a look at FreeTDS.