BUL INSERT WITH FILEFORMAT

  • Hi,

    Can you please anybody help me to resolve the following error..

    I have attached Data file and Format file.

    Query is

    CREATE TABLE TEST

    (Client VARCHAR(100),[Site_Ref_No] VARCHAR(100),SITE VARCHAR(200),

    [Address 1] VARCHAR(200),[Address 2] VARCHAR(200),[Address 3] VARCHAR(200),

    City VARCHAR(200),State VARCHAR(200) ,[Zip Code] VARCHAR(200),

    Country VARCHAR(200),Account VARCHAR(200),[Account id] VARCHAR(200),

    Vendor VARCHAR(200),[Account Type] VARCHAR(200),[Group Bill] VARCHAR(200)

    )

    BULK INSERT TEST FROM 'C:\TEST\DATA.TXT'

    WITH

    (

    FORMATFILE='C:\TEST\FORMAT.TXT',

    FIRSTROW = 1

    )

    SELECT * FROM TEST

    DROP TABLE TEST

    I am getting the following error...

    Msg 4832, Level 16, State 1, Line 9

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

    Msg 7399, Level 16, State 1, Line 9

    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 9

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

    Regards

    Ram...

    🙂

  • I've seen that in text files with blank lines in them. Try cleaning that up and see if it helps.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • I tried but Getting the same issue..

    Here I felt the issue is with the terminators in the formatfile to import an integer value..

    🙂

  • Try this format file

    7.0

    13

    1 SQLCHAR 0 0 "\"" 0 Quote

    2 SQLCHAR 0 0 "\",\"" 1 Client

    3 SQLCHAR 0 0 "\",\"" 2 Site_Ref_No

    4 SQLCHAR 0 0 "\",\"" 3 Site

    5 SQLCHAR 0 0 "\",\"" 4 Address_1

    6 SQLCHAR 0 0 "\",\"" 5 Address_2

    7 SQLCHAR 0 0 "\",\"" 6 Address_3

    8 SQLCHAR 0 0 "\",\"" 7 City

    9 SQLCHAR 0 0 "\",\"" 8 State

    10 SQLCHAR 0 0 "\",\"" 9 Zip_Code

    11 SQLCHAR 0 0 "\",\"" 10 Country

    12 SQLCHAR 0 0 "\"," 11 Account

    13 SQLCHAR 0 0 "\r\n" 12 Account_id

  • Thanks Steve..

    It works for me..

    Regards

    Ram...

    🙂

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

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