Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

import a DBF file in SQL Server using SQL Script

How can I import a .dbf file into SQL Server using a SQL script?

Found answers from this post, but unfortunately none of them work to me :( :

  • Trying to Import FoxPro DBF File to SQL Server and
  • How to import a DBF file in SQL Server

When I'm trying this code :

SELECT * 
INTO [APP_DB]..[BILLHEAD] 
FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver; SourceDB=D:\DBF; SourceType=DBF', 'SELECT * FROM BILLHEAD')

I get this error:

OLE DB provider "MSDASQL" for linked server "(null)" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". Msg 7303, Level 16, State 1, Line 1 Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "(null)".

And also, when trying this :

SELECT * 
FROM openrowset('VFPOLEDB','D:\DBF\BILLHEAD.dbf';'';
                '','SELECT * FROM BILLHEAD')

I get this error :

Msg 7438, Level 16, State 1, Line 1
The 32-bit OLE DB provider "VFPOLEDB" cannot be loaded in-process on a 64-bit SQL Server.

I don't want to download any third party application. That's why I'm trying all the possible solution and I need your help now guys. I'm creating a small application to import .DBF files into SQL Server.

Regards,

like image 648
Gimo Gilmore Avatar asked Nov 01 '22 09:11

Gimo Gilmore


1 Answers

You are using 64-bit SQL sever, but FoxPro OLE DB driver is 32-bit. You need to consult this article which discusses how to use the 32-bit OLE DB driver with 64-bit SQL Server.

like image 160
Alan B Avatar answered Nov 15 '22 05:11

Alan B