Using Bulk Insert with DBF files. RRS feed

  • Question

  • Hey Guys.

    I am new to SQL Server and am trying to write a procedure to import 500 DBF files. (<-- This will happen every two weeks... so looking to automate it a little bit...) I want the procedure to loop through the folder and insert each DBF file into its own table. Here is what I have so far: (I am thinking to finish this procedure and write a batch that loops through the file and runs the procedure on each one.)

    create table [tempDBF](
        [DOC_NO] varchar(14) not null,
        [FAPC] varchar(5) not null,

    create table ['"+@fileName+'"](
          [DOC_NO] varchar(14) not null,
        [FAPC] varchar(5) not null,

    @pathName varchar(200)
    @fileName varchar(100),

    DECLARE @sqlQuery varchar(2000)
        SET @sqlQuery = "BULK INSERT tempDBF FROM '"+@path+@fileName+"' WITH (--How do I specify DBF format?--)

    EXEC (@sqlQuery)

    INSERT INTO '"+@fileName+"'
    SELECT *
    FROM tempDBF

    I am not sure how to set the BULK INSERT for DBF format. Any ideas?

    Any help would be greatly appreciated.


    Tuesday, February 20, 2007 4:05 PM

All replies

  • Bulk insert is only for text files.  You cannot directly import DBF files.  Look at SSIS to write a package to import the files.  That is what SSIS is for.

    Tuesday, February 20, 2007 4:41 PM