Labels

Wednesday, August 24, 2011

Load Text File into SQL Server

SQL Bulk insert

ADO.NET SQLBulkCopy

In ADO .NET, SqlBulkCopy is the object that helps you to perform a bulk copy.  You can use a DataReader or DataTable as source data store (you can load your data from SQL database, Access database, XML or ... into these objects easily) and copy them to a destination table in database.

Copying only updated rows, Mapping Columns
Using a DataReader - most efficient way to bulk copy data between SQL Servers using .NET


SQL Server Integration Services

Running SSIS package programmatically




--- Create a temp table to hold the data
CREATE TABLE TmpStList
(
 username varchar (100) NOT NULL,
 userpassword varchar (100) NOT NULL,
)
go

--bulk insert from a text file
BULK INSERT tmpStList FROM 'C:\temp.txt' WITH (FIELDTERMINATOR = ',')
go

-- insert into a destination table
INSERT memphisgives2008 (username,userpassword)
 SELECT username, userPassword 
FROM tmpStList




No comments:

Post a Comment