devxlogo

Accessing DBF from SQL Server 7.0 Using OpenQuery

Accessing DBF from SQL Server 7.0 Using OpenQuery

I read a SQL tip titled “Using Distributed Queries on SQL Server 7.0.” I think this is a great follow up to that tip. This is especially useful for those who want to migrate a selected DBF structure to SQL Server or to query DBF using the query analyzer.

SQL Server 7.0 provides two stored procedures (OpenQuery and OpenRowSet) for accessing different database formats, be it a DBF, MDB, or any other OLE DB- or ODBC-compliant database. The following example illustrates how OpenQuery is used.

 USE Master  -- sp_addlinkedserver can be executed 
only using the master databaseDECLARE @cConnStr VARCHAR(256) SET @cConnStr = 'DSN=GLDBF;DefaultDir=c:data;
DriverId=277;FIL=dBase IV' /* GLDBF is a datasource configured in your physical
server where the data is located. It is configured using the ODBC Data Source Administrator. DefaultDir
contains your DBF files. */EXECUTE sp_addlinkedserver @server=MyServer,
@srvproduct='dBase IV',@provider='MSDASQL', @provstr= @cConnStr /* use sp_addlinkedserver to add a virtual server
for your data source. */ select * from openquery(MyServer,'select * from
customer') /* you can now use openquery to access DBF files. */
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist