Importing DBF files into SQL Server

Problem

The company I work for has many data files that are stored in a DBF format which I need to load into SQL Server.  I’ve looked through the drivers available in the Import/Export Wizard and cannot find one I can use to import the files. Do you know of any methods I can use to import these files?

Solution

The good news is that you were heading in the right direction with the Import/Export Wizard.

In my example I am going to update the DBF file listed below. 

Files that comprise a shapefile 

When you open the Import/Export Wizard there are a number of data sources you can choose from, and if you are running on a 64-bit operating system then there may be fewer choices. Select the Microsoft Office 12.0 Access Database Engine OLE DB Provider. When you select this option a Properties button will appear as shown below.  Click on the Properties button.

Select the driver to use

The Data Link Properties window should appear. Select the All tab. Within this tab there are two properties to be set for importing the DBF file-the Data Source and Extended Properties values:

The All tab of the Properties window

Unlike other import processes, the data source should be set to the directory in which the shapefile files are located, not the actual DBF file:

Set the source directory

The extended properties should be set to whatever dBase version was used to create the DBF file:

Set the driver

If the version is not known then you can try each version until successful. If you enter the wrong version you will get an immediate error message similar to the one below:

Wrong driver error

The remainder of the import process is similar to other import processes. Select the destination type and SQL Server instance, if applicable:

Set the destination driver and location

Select the method through which the source data will be selected:

Set the selection method

Either select a current table or create a new table to house the data:

Set the table or other device that will house the data

Select whether you want to save the package and execute immediately:

Save the package

Finally, check to make sure that all steps executed successfully and whether the number of imported rows match what was expected:

Ensure completion of the import

Next Steps

4 Comments

  1. Hi Christian,
    you may need to install the MS Office components to get these other options.

    https://www.microsoft.com/en-us/download/details.aspx?id=54920

    Also, I noticed I get different options if I use the SQL Server Import/Export app versus right-clicking on a database and selecting Tasks > Import Data.

    -Greg

  2. Thank You for this article, it has enabled me overcome the challenge of importing from .dbf to MS SQL.
    Something to note, MS SQL will throw and error if it puts single quotes on the source file name. To overcome this, perform a preview of the data map, copy the SQL that is being executed, then press back and instead of copying the data, write a query instead. Paste the SQL you copied as your query and edit to remove the single quotes on the FROM table. Once this is done, your import will now have a query as the source, specify the name of your destination table and proceed as guided in this article.
    Once again, Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *