Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Posts
    3

    Unanswered: Need help for bulk insert

    My problem is a ASCII-file with fieldterminator=';', rowterminator='\n' and a header-line (Firstrow=2). The SQL-Server didn't find the header-line because in this line are no fieldterminators. How can I import this file looks like:
    1. row: ****This is a test-file***
    2. row: field1;field2;field3;field4;field5

    Thanks

  2. #2
    Join Date
    Dec 2004
    Posts
    47
    Do u have DB manager cleint installed in ur machine... it have data management utility thru which u can import data easily.. and what u r saying about the header line, little bit confused is it the table feild names u r mentioning... take it off..... how can an automized thing identify it...

  3. #3
    Join Date
    Jan 2005
    Posts
    3
    OK, any more infos:
    I have installed the full sql-server, bat I have to import the file automaticly from my C++ programm. Therefor I have write a saved procedure, in wich the import and any other tasks will done. I can't use any manager for the import. The most problem is, that the sql-server checked first the fieldterminator and then the firstrow-value. But in my case there are no fieldterminators in the first line, wich I will not import.
    I hope this informations helps for this problem.

  4. #4
    Join Date
    Mar 2004
    Posts
    480
    Look at LOAD DATA INFILE in the manual. It tells you explicitly how to skip lines from your input file. at the end of your load data infile command add
    Code:
    IGNORE 1 LINES
    Yes lines needs to be plural even though it is only 1 line you are ignoring.
    You could ignore as many lines at the beginning of the file that you want to.

  5. #5
    Join Date
    Jan 2005
    Posts
    3
    Thank you for answer, but this is not my problem,

    my problem is, that I have to generate the insert-statement in a procedure. I can't use any managers or format files, because I don't know the file structur in design-time. During runtime I create the bulk insert statement with any parameters. In one time there are ";" for fieldterminators, in other times tabs and so on.
    My bulk insert statement works fine, but if the first line don't have any fieldterminators, the import isn't correct.
    The bulk insert statement havn't any ignore lines parameter, there is only the firstrow parameter.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •