Posts
120
Comments
117
Trackbacks
22
SqlBulkCopy
I just discovered the SqlBulkCopy class in .Net 2.0, and it seems awesome!  Now I don't have to shell out to BCP anymore!  We'll see though, I haven't done any performance testing yet...
posted on Tuesday, April 10, 2007 10:06 PM Print
Comments
Gravatar
# re: SqlBulkCopy
AzamSharp
4/10/2007 11:39 PM
Hi,

Check out my article on SqlBuildCopy.
http://gridviewguy.com/ArticleDetails.aspx?articleID=233
Gravatar
# re: SqlBulkCopy
Alex Bransky
4/10/2007 11:46 PM
Cool, thanks. Right now I'm using a DataTable that's built from a fixed-field text file, so it will be interesting to see what BatchSize works best.
Gravatar
# re: SqlBulkCopy
Bruce Dunwiddie
4/11/2007 1:26 PM
The batch size is going to make less of a difference than if you can eliminate the DataTable from the mix. You're wasting a lot of resources trying to load all the data into memory first instead of streaming the data to SqlBulkCopy directly from the file.
Gravatar
# re: SqlBulkCopy
Alex Bransky
4/11/2007 6:07 PM
I don't know how to parse the fields out directly to SqlBulkCopy without the DataTable in between.
Gravatar
# re: SqlBulkCopy
Bruce Dunwiddie
4/12/2007 7:16 PM
Check out my site and see how I go about it, FixedWidthDataReader in your case. I'm not saying I've got the only component that can do it, it just bugs me when I see solutions for large data that just changes the scaling metrics, doesn't necessarily provide a permanent fix. I'm pondering putting together a nice fully documented plea to MS that they start looking at enterprise level data scalability issues in a cross product line perspective as data mining and management is becoming a larger and larger issue that everyday developers are having to deal with without framework tools built for the job.
Gravatar
# re: SqlBulkCopy
Alex Bransky
4/17/2007 6:02 AM
FYI, one irritating thing about SqlBulkCopy (irritating if you don't know that it does it) is that you have to specify the identity column in your DataTable before you call WriteToServer, otherwise the columns will map incorrectly. If you want to write the values in the identity column to the db there's a KeepIdentity option.
Gravatar
# re: SqlBulkCopy
web development company
8/10/2009 8:39 PM
Humm... interesting,

I used bulkcopy class before, but I rarely use it any way

Thanks for writing, most people don't bother.

Post Comment

Title *
Name *
Email
Url
Comment *  
 
News