SQL 访问链接服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5873673/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL to Access linked server
提问by dcinadr
I am trying to add a linked server to a Access database. I am using the following SQL code to do this.
我正在尝试将链接服务器添加到 Access 数据库。我正在使用以下 SQL 代码来执行此操作。
exec sp_addlinkedserver
@server = 'Test',
@provider = 'Microsoft.Jet.OLEDB.4.0',
@srvproduct = 'OLE DB Provider for Jet',
@datasrc = '\srv\public$\CM Database\Data\sysConfig_dat.mdb'
go
EXEC sp_addlinkedsrvlogin Test, FALSE, Null, Admin, Null
but when i run this...
但是当我运行这个...
select * from Test...tblProduct
i get this error...
我收到这个错误...
OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode. what am i doing wrong?
OLE DB 提供程序“Microsoft.Jet.OLEDB.4.0”不能用于分布式查询,因为该提供程序被配置为在单线程单元模式下运行。我究竟做错了什么?
I am using SQL Server Management Studio 2008 on a 32 bit system.
我在 32 位系统上使用 SQL Server Management Studio 2008。
回答by dcinadr
I figured it out...
我想到了...
The server running SQL Server is a 64Bit machine. The typical data connectivity component drivers did not work with this machine (ie the download that installs the Microsoft.Jet.OleDB.4.0 as a provider). I had to download the components for Access 2010 which has a 64Bit option.
运行 SQL Server 的服务器是 64 位机器。典型的数据连接组件驱动程序不适用于这台机器(即安装 Microsoft.Jet.OleDB.4.0 作为提供程序的下载)。我必须下载 Access 2010 的组件,它有一个 64 位选项。
That installs the Microsoft.ACE.OLEDB.12.0 as a provider and I can use the SQL command that BradBenning mentioned in his post.
这将安装 Microsoft.ACE.OLEDB.12.0 作为提供程序,我可以使用 BradBenning 在他的帖子中提到的 SQL 命令。
回答by BradBrening
Try using the Microsoft ACE OLEDB provider:
尝试使用 Microsoft ACE OLEDB 提供程序:
EXEC sp_addlinkedserver
@server = 'Test'
,@provider = 'Microsoft.ACE.OLEDB.12.0'
,@datasrc = '\srv\public$\CM Database\Data\sysConfig_dat.mdb'
,@srvproduct='Access'
GO