Import DBF files into Sql Server

jumbojs picture jumbojs · May 19, 2009 · Viewed 22.5k times · Source

I need a little help figuring this out because I'm new to stored procedures. I am trying to import a .DBF table into Sql Server 2008 using this store procedure.

CREATE PROCEDURE spImportDB
-- Add the parameters for the stored procedure here

AS
BEGIN

-- Insert statements for procedure here

 SELECT * into Products
 FROM OPENROWSET('vfpoledb','C:\Users\Admin\Doc\Data\DBF',
 'SELECT * FROM MyTable')

END
GO

I receive this error. The OLE DB provider "vfpoledb" has not been registered.This isn't true, I've installed it and it works fine in my other application.

I've also tried running it this way with this provider but I receive this error message Cannot initialize the data source object of OLE DB provider "Microsoft.Jet.OLEDB.4.0" for linked server "(null)".

CREATE PROCEDURE spImportDB
-- Add the parameters for the stored procedure here

AS
BEGIN

-- Insert statements for procedure here

 SELECT * into Products
 FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','C:\Users\Admin\Doc\Data\DBF',
 'SELECT * FROM MyTable')

END
GO

What's the easiest way to create this stored procedure? I want it to be a stored procedure not a wizard or program so please don't give me any programs.

Answer

Eduardo Molteni picture Eduardo Molteni · May 20, 2009

You can try

SELECT * into SomeTable
FROM OPENROWSET('MSDASQL', 'Driver=Microsoft Visual FoxPro Driver;
SourceDB=\\SomeServer\SomePath\;
SourceType=DBF',
'SELECT * FROM SomeDBF')

from this previous question