How to load the bulk data in datadase from text file

  • I try to load the text file to sqlserver in my local system,in text file i've take only one column

    and take the to columns in database now i load the file then i give the FIELDTERMINATOR= '\t', ROWTERMINATOR= '',.

    so evry time i give the 'tab' each and every column value finally give the 'enter' in text file after that save the text file.than only it'll execute,with out giveing tab,enter it 'll show an error msg like

    (Msg 4832, Level 16, State 1, Line 1

    Bulk load: An unexpected end of file was encountered in the data file.

    Msg 7399, Level 16, State 1, Line 1

    The OLE DB provider "BULK" for linked server "(null)" reported an error. The provider did not give any information about the error.

    Msg 7330, Level 16, State 2, Line 1

    Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".)

    so with out giveing tab and enter how i can load that file

  • Don't use either terminator in the code... the defaults are probably correct for your single column text file.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi,

    Plz make sure source file and target table column should be same and use this script :

    BULK INSERT table_name FROM 'D:\file.txt' WITH (FIELDTERMINATOR = '\t',firstrow=1)

    firstrow is optional :

    Best Regards
    Faheem latif
    Senior Database Architect
    Genie Technologies (Pvt.) Ltd.

  • You need to explain the rest... first row, even if you skip it, must have the same number and type of delimiters or the second row may cause an error or be included as part of the first row in error.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply