Best way to reinvent bulk insert?

  • Thread starter Thread starter Siegfried Heintze
  • Start date Start date
S

Siegfried Heintze

Which is more efficient: a long series of SQL INSERT statements or
deserializing a dataset from XML and saving it to the table?

If I fill a dataset with current sample data and serialize it to XML, can I
expect to use that as a template to subsequently populate the table in the
future?

This way I can keep the XML under version control as well.

What function to I call to save a deserialized data set to a table?

We have been using bulk insert with sqlcmd but that is difficult to debug
and is specific to SQL Server.
 
Use SqlBulkCopy. It's dramatically faster than any SQL-based approach. It
can accept rowsets from anything that can expose IBindingList or has a .NET
data provider, OLE DB provider or ODBC driver.

--
__________________________________________________________________________
William R. Vaughn
President and Founder Beta V Corporation
Author, Mentor, Dad, Grandpa
Microsoft MVP
(425) 556-9205 (Pacific time)
Hitchhiker’s Guide to Visual Studio and SQL Server (7th Edition)
____________________________________________________________________________________________
 
Will it work for XML to MSAccess? Judging by the name space, it (SqlBulkCopy)
is specific to SQL Server.

I want to write a generic utility that will save and load XML to/from excel,
MSAccess, MySQL, SQL Server etc...

Can I do that by serializing/deserializing data sets? Is that the best way?

Thanks,
Siegfried
 
Back
Top