开发者

Query access database from SQL management studio without using linked servers

How do I query a MS Access database directly from SQL M开发者_如何学JAVAanagement 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?


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.


How about OPENROWSET().


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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜