Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Enterprise
Expertise: All
Aug 25, 2000



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 database DECLARE @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. */
Jojit Soriano
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date