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. */
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS