loading data from text files

Giganews Newsgroups
Subject: loading data from text files
Posted by:  Ted (r.ted.bye…@rogers.com)
Date: 3 Aug 2006

In MySQL, I use "LOAD DATA INFILE 'my_path/data_file.txt'" to load data
from a plain text file.  Of course, the actual statement is a bit more
complex once one considers the various options (e.g. comma delimited vs
tab delimited, record termination strings, &c.).

My problem is that I have yet to find the equivalent within MS SQL
server.  I did find a LOAD statement in T-SQL, but at first glance it
seems to do something completely different.

How does one normally load data from a plain text file into a table in
MS SQL?  This needs to be relatively efficient since, once in
production, it will be used to load tens of megabytes of data into the
database (a feed from a data provider).  Is it flexible enough to allow
me to specify whether the fields are tab delimited vs comma delimited,
optionally enclosed by quotes, record termination charactors, &c.?

All I really need is direction to the right part of the T-SQL reference
(MS SQL Server 2005).  Anything else, such as examples, is icing on the
cake.

Thanks

Ted

Replies