Data Access BlogTips for implementing a Data Access Layer with .NET

Bulk insert in SQL Server 2005 using ADO.NET and XML

Written on November 7, 2008 by Luis Ramirez

Creating a bulk insert using a Stored Procedure and XML

One common task that developers face is to insert multiple records to a database. There are many different approaches to solve a batch insertion but one effective method is to use a XML file containing all the records to be inserted.

Creating the database tables

Create a Developer table and an Articles table. The Developers table stores developer names and the Articles table stores articles written by each developer.

CREATE TABLE [dbo].Developer (
  DeveloperId INT IDENTITY NOT NULL PRIMARY KEY,
  FirstName VARCHAR(64) NOT NULL,
  LastName VARCHAR(64) NOT NULL
)

« Back to Blog