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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pankajGoyal1958
    New Member
    • Nov 2011
    • 1

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

    I am trying to import csv file into sql server.

    csv file data is

    C,FD,20111231,0 8,000,C,ECB,FLL ,FLL,C1,,201111 1009592368,,,,,
    C,IS,20111231,0 5,000,C,KWR,TPA ,TPA,F3,,201111 1009592368,,,,,

    Bulk insert statement :

    BULK INSERT dbo.TB_SAILING_ STAG
    FROM 'C:\s1.csv'
    WITH
    (DATAFILETYPE = 'native',
    Keepnulls, FIELDTERMINATOR =',',
    FORMATFILE ='C:\PersonForm at_n.fmt',
    ROWTERMINATOR ='\t',KEEPIDENT ITY
    )

    getting below error

    Msg 4832, Level 16, State 1, Line 2
    Bulk load: An unexpected end of file was encountered in the data file.
    Msg 7399, Level 16, State 1, Line 2
    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 2
    Cannot fetch a row from OLE DB provider "BULK" for linked server "(null)".
  • bhooma
    New Member
    • Nov 2011
    • 5

    #2
    Looks like your csv file has some control char in the end. Open up in textpad and check for hidden characters.

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      You are already using a format file. Let it control how rows are parsed and inserted. You can remove the terminators options.

      Good Luck !!!

      ~~ CK

      Comment

      • lavandeep garg
        New Member
        • Jan 2014
        • 1

        #4
        your format file might be like:
        1 SQLCHAR 0 4 "" 1 LAYOUT_SYUBETSU Japanese_CI_AS


        2 SQLCHAR 0 8 "" 2 DATA_DATE Japanese_CI_AS



        use this format :
        1 SQLCHAR 0 4 "" 1 LAYOUT_SYUBETSU Japanese_CI_AS
        2 SQLCHAR 0 8 "\r\n" 2 DATA_DATE Japanese_CI_AS


        means "\r\n" for end of the file in the last statement. This will solve your problem.
        let me know if problem still persists.

        Comment

        Working...