Query access database from SQL management studio without using linked servers
Asked Answered
G

3

14

How do I query a MS Access database directly from SQL Management Studio, without using a linked server?

Ie. something like

SELECT * FROM ["C:\Data\Accessdb.mdb"].[SomeTableInAccessDB]

Obviously this won't work but is there a away to specify the access database details within a sql query?

Gyrus answered 6/4, 2010 at 9:59 Comment(0)
R
18

You can use OPENROWSET or OPENQUERY. For example (per Microsoft's Northwind):

 SELECT CustomerID, CompanyName
   FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',
             'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb';
             'admin';'',Customers)

Adding a linked server just allows ease of configuration, so different processes can use the connection without having to specify connection details. I don't believe a Linked Server actually adds any functionality that can't be obtained through one of the two OPEN options.

Readily answered 6/4, 2010 at 16:17 Comment(0)
P
3

How about OPENROWSET().

Persson answered 6/4, 2010 at 10:2 Comment(0)
S
0

If using 64bit server, use Microsoft.ACE.OLEDB.12.0 as provider:

SELECT CustomerID, CompanyName
   FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
             'C:\Program Files\Microsoft Office\OFFICE11\SAMPLES\Northwind.mdb';
             'admin';'',Customers)
Shawannashawl answered 3/11, 2020 at 14:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.