Vault9 Modding Vault9 Graphics Vault9 Code Vault9 Net Vault9 OS Vault9 Gaming Vault9 ChillZone Vault9 Tech Vault9 Archives       Vault9 Global9       Vault9 Fusion     Vault9 Blog     Vault9 Network          
 

Please Note!

This is a read-only board, no new topics or registrations are allowed. The Code Vault has moved to http://forums.vault9.net - Be sure to find more information there!


 
Reply to this topicStart new topic
> ASP News->Using SqlBulkCopy To Perform Efficient Bulk SQL Operation
post Oct 20 2009, 05:00 PM
Post #1


Guru
Group Icon

Group: Administration
Posts: 1,224
Joined: 24-July 05
Member No.: 4,918

Sex: Male




Over the years I've worked on a number of projects that have shared a common requirement - the ability for users to quickly import large amounts of data into a back end SQL
Server database. One such project was a web application used by teachers and other staff members. The software was initially purchased for just two schools in the district,
but was soon expanded to encompass other schools. Every few months one or two new schools were brought into the fold; every time a new school was added an administrative
user would have to create accounts for the new teachers and staff members so that they could sign into the site. Initially, the application offered a web page for the
administrator to create new user accounts one at a time, but this interface quickly became tedious and impractical once larger schools with upwards of 100 users were
brought online.



To allow school administrators to quickly import new users we created a web page from which a user could upload an Excel spreadsheet that contained the one row for every new
user; the columns in the spreadsheet mapped to table columns in the database. After uploading this spreadsheet, the application would walk through each row and insert a record
into the table. Through this mechanism an administrator could create the 100+ user accounts by first building an Excel spreadsheet (something many of the schools already had
on file) and then upload that spreadsheet. This technique may sound familiar - in [url="http://www.4guysfromrolla.com/articles/022708-1.aspx"]Importing an Excel Spreadsheet
Using Typed DataSets and TableAdapters[/url], author Nannette Thacker walked through building such an interface.



While the described approach works well when importing hundreds of records, it starts to seriously slow down when importing thousands or tens of thousands of records.
The slowdown is due to the fact that each imported record sends its own INSERT statement to the database. This results in a lot of "chatter" between the web
server and the database server. If you are importing data to Microsoft SQL Server the good news is that this process can be dramatically sped up using ADO.NET's
SqlBulkCopy class. In my testing, importing 10,000 records using
the one INSERT statement per import record took more than three seconds to complete; using SqlBulkCopy took a fraction of a second.



This article look at how to use the SqlBulkCopy class to efficiently execute bulk operations against Microsoft SQL Server. Read on to learn more!

Read More >



Source: http://www.4guysfromrolla.com/articles/102109-1.aspx
User is offlineProfile CardPM
+Quote PostGo to the top of the page
post Oct 20 2009, 05:00 PM
Post #


Member


Group: Administration

Joined: Today, 01:31 PM





Quote PostGo to the top of the page

Reply to this topicStart new topic



 



- Lo-Fi Version Time is now: 19th March 2010 - 01:31 PM
Privacy Policy
South Africa's Top Sites Kinetiq