Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Load Data Infile with MS-SQL?

Status
Not open for further replies.

innu

Programmer
Jun 13, 2001
40
AT
Hi!

I want to load a CSV-File into my database.

I just thought that it should go like this:

LOAD DATA INFILE 'Myfile.csv'
INTO TABLE mytable
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n'

but he says only: "Syntax Error"

Does anyone can help me? What's wrong? Does this Instruction exists in MS-SQL?

I'm lucky with each answer,

thx.
 
Sorry, but I'm not really good in English and I'm just a Newbie in this forum and in SQL.

What do you mean, that I should look at the DTS utility. What is DTS?

sorry, but I'm only a little boy, in a big, big world... ;-)
 
In your SQL Server 7.0 menu group there should be "Books Online", the reference books for SQL Server (always a good first stop!)
Looking up DTS in the index will show you that it is the Data Transformation Services and how to use it.

However....
you might want to look up the BULK INSERT command as this is probably more relevant to your original question.
 
oh, thank you.

Now I know what you mean. It's not easy, if you have a german version of MS-SQL :)

But it's really bad, that there is no such instruction like in My-SQL :-(
 
The equivalent MS-SQL Server command is

BULK INSERT MyTable
FROM 'path\myfile.csv'
WITH
(FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n')

As suggested, the SQL Books Online are a good resource. They document and explain Bulk Insert, BCP (Bulk Copy Program), and DTS (Data Transformation Services) - the three main ways to import data from flat files to MS-SQL Server.

Bulk Insert is a T-SQL command for importing flat files. BCP is a command line utility for importing and exporting flat files. DTS is the most versatile and will import and export a wide variety of file and database formats. Terry

The reason why worry kills more people than work is that more people worry than work. - Robert Frost
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top