My latest article has just been posted over at SQLTeam.com
.NET Framework 2.0 introduces a very handy new class in the System.Data.SqlClient namespace called SqlBulkCopy that makes it very easy and efficient to copy large amounts of data from your .NET applications to a SQL Server database. You can even use this class to write a short .NET application that can serve as a "middleman" to move data between database servers.
If you ever need to move large amounts of data to SQL Server from a .NET application, SQLBulkCopy
is the way to go. What's great about it is that you can use a populated DataTable as the source, or anything that implements IDataReader
. This means that you can use SQLBulkCopy to quickly move data from any OLEDB/ODBC datasource to SQL Server.
Informal testing shows that it is about 4 times as fast as executing INSERT statements over and over when copying large amounts of data from a DataTable, and it certainly is much shorter and easier to write and maintain.
I hope you find the article and the examples given useful.