Pages

Sunday, August 31, 2008

Load text file into SQL Server

Recently i came accross a situation where i have to load the text file data into SQL Server with simple code.
i had several options to do this but i went to the basics of SQL Server. i.e. There is one feature which was started from 7.0 i.e. BULK INSERT.

look at the sample data
-----------------------
jhonson,glen,glen@ge.com
nicole,kid,kid@nicole.com
chai,nee,nee@usa.com

BULK INSERT tmpStList FROM 'c:\data.txt' WITH (FIELDTERMINATOR = ',')

Thats it. Its so simple to do it

No comments: