Archive for December, 2011

When you have an XML file to copy its data into Sql Server data table, using the following approach will really be helpful, efficient and easy. Here, I’m using SqlBulkCopy class (Namespace: System.Data.SqlClient) to load all data contained in the XML file into a pre-defined Sql table.

Pre-requisites

The only pre-requisite for this activity is to have a predefined table to hold XML data. (The easy ways is to have a 1:1 mapping table while defining the column names of the table as XML attributes.) You can have your own columns like identity column, auto populate column etc. J

Code:

(more…)