Bulk insert formatfile problem

  • Hello, All.

    Trying to use a bulk insert and getting the following message:

    Server: Msg 4829, Level 16, State 1, Line 1

    Could not bulk insert. Error reading destination table column name for source column 23 in format file 'E:\Inetpub\wwwroot\RiskWeb\bool.fmt'.

    Here is my bool.fmt file

    7.0

    23

    01 SQLCHAR 0 9 "," 0 a

    02 SQLCHAR 0 9 "," 0 b

    03 SQLCHAR 0 9 "," 0 c

    04 SQLCHAR 0 9 "," 0 d

    05 SQLCHAR 0 9 "," 1 BooleanID

    06 SQLCHAR 0 9 "," 0 f

    07 SQLCHAR 0 9 "," 0 g

    08 SQLCHAR 0 9 "," 0 h

    09 SQLCHAR 0 9 "," 0 i

    10 SQLCHAR 0 9 "," 0 j

    11 SQLCHAR 0 9 "," 0 k

    12 SQLCHAR 0 9 "," 0 l

    13 SQLCHAR 0 9 "," 0 m

    14 SQLCHAR 0 9 "," 0 n

    15 SQLCHAR 0 9 "," 0 o

    16 SQLCHAR 0 9 "," 0 p

    17 SQLCHAR 0 9 "," 0 q

    18 SQLCHAR 0 9 "," 0 r

    19 SQLCHAR 0 9 "," 0 s

    20 SQLCHAR 0 9 "," 0 t

    21 SQLCHAR 0 9 "," 0 u

    22 SQLCHAR 0 80 "," 2 BooleanDesc

    23 SQLCHAR 0 255 "\r\n" 3 BooleanExp

    I only want to import the 5th, 22nd and 23rd columns, but something is not right.  Here is my stored procedure:

    CREATE PROCEDURE BooleanIDsFMT

    (

      @FilePathName varchar(100)

    )

    AS

    TRUNCATE TABLE BooleanTest

    DECLARE @SQL varchar(1000)

    BEGIN

      SET @SQL = "BULK INSERT BooleanTest FROM '" +@FilePathName+ "' WITH (FORMATFILE = 'E:\Inetpub\wwwroot\RiskWeb\bool.fmt')"

    END

    EXEC(@SQL)

    GO

    Any help is appreciated!

    Harry

  • This was removed by the editor as SPAM

  • The error suggests there is problem with the destination table definition. Make sure the column name and data type match.

    It would also be helpful if you post the table definition and sample of import data file.

  • Recreate the fmt file from the Bulk Insert tool`s format file generate option.

    This might help.

     

     

  • Hi all,

    I am also getting the same error.

    Server: Msg 4829, Level 16, State 1, Line 1

    Could not bulk insert. Error reading destination table column name for source column 17

    Can any one help me.

    Thanks in advance.

    VJ

  • Hi,

    I could resolve it in the end. Generated the format file again and it just worked fine.

    Also check the spacing in the format file.

    Vj

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

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