Get XML data into SQL Server

VBAHole22

Well-known member
Joined
Oct 21, 2003
Messages
432
Location
VA
Someone sends me an xml file in a set format. I want to take that and get all of the records into a blank SQL Server table. I can build the table first because I know the fields.
What is the fastest way to get this accomplished in C#?
 
Havent had much luck getting responses there and this seems like something that is trivial and can easily be accomplished in .NET.
Yet after an hour of Googling I have only come up with SQL stored procedures to get it done.
Im not really sure what defines a General question and I didnt realize these forums were so well policed. Ill try not to step out of line again.
 
Incidentally, the term xml cannot be used to search these forums. I realize that small words like the and and dont contribute much to a search query but isnt something like xml distinctive enough that users could be allowed to search on it? Much like a search for awk or rpc.
 
Could you not load the xml into a typed dataset and use that to update the database? Alternatively you could load the file into a XmlDocument and loop over its contents, or even use a XmlReader to read through the file and update the db manually
 
What I wound up doing was just that. I looped over the xml and manually created an insert statement to put the records in. Its not pretty. Im testing with 5 records. Go time will be 500,000 records.

The dataset.update method is, from my exploration, something that recognizes changes that you have made to a dataset since you call a Fill on it. Im filling it from the xml and not making any changes, so MS has over-engineered that bit for me.
 
Back
Top