Solved

Can I query MDB file via SQL server (not convert to MDF)

Posted on 2001-07-25
5
920 Views
Last Modified: 2013-12-05
I use MS SQL 7 and have a MDB file in its local harddisk.

If I don't convert my MDB file to MDF, can I query this MDB file via SQL server?

Thank you very much.
0
Comment
Question by:saikit
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:chrhedga
Comment Utility
First set up the link:

sp_addlinkedserver 'Nwind', 'Access 97', 'Microsoft.Jet.OLEDB.4.0', 'c:\mydata\Nwind.mdb'

Next, logininfo:

sp_addlinkedsrvlogin 'Nwind', false, 'Joe', 'Admin', NULL

Query like this:

SELECT * FROM Nwind...Employees
0
 

Author Comment

by:saikit
Comment Utility
The MDB file is Access 2000.

I'm new to SQL server, would you please give more details on doing this?

Thanks.
0
 

Author Comment

by:saikit
Comment Utility
How to specify the MDW file for the Access 2000 MDB for the linkedserver ?
0
 
LVL 1

Accepted Solution

by:
chrhedga earned 200 total points
Comment Utility
Sorry, I am no expert on Access (actually I don't think I've ever created a table in access... ) so I don't know what a MDW file is. I got it to work by doing this:

1. I created an Access database, with one table called foo. This table had one column called bar of type Number (Long Integer). I added a few rows to this table in Access and then closed Access.

2. I executed the following code in SQL Server (SQL Server running on the same machine as the Access database was placed on, make sure this machine has the Jet provider installed):

EXEC sp_addlinkedserver
   @server = 'AccessTest',
   @provider = 'Microsoft.Jet.OLEDB.4.0',
   @srvproduct = 'OLE DB Provider for Jet',
   @datasrc = 'C:\db1.mdb'
GO

sp_addlinkedsrvlogin 'AccessTest', false, 'sa', 'Admin', NULL
go

select * from AccessTest...foo

This resulted in the following showing up in my results window of Query Analyzer:

bar        
-----------
2
6
81
5
54
0
 

Author Comment

by:saikit
Comment Utility
Thanks. I followed you example and successed.

My Client program is using DSN (SQL server driver) to connect the SQL server, but the LinkedServer doesn't showing in the database list of the SQL server.

How to make linked server showing in the DB list?


Thanks.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now