简体   繁体   English

从sql server读取2010的Access数据库中的数据

[英]Read data from 2010's Access database from sql server

I'm going to tell you my environment: Windows Server 2012 R2 64, ACCESS 2010 32, SQL SERVER 2008 R2 64 running with the Administrator account, AccessDatabaseEngine 32. I need connect the sql to 2010's bbdd access. 我将告诉您我的环境:使用管理员帐户运行的Windows Server 2012 R2 64,ACCESS 2010 32,SQL SERVER 2008 R2 64,AccessDatabaseEngine 32.我需要将sql连接到2010的bbdd访问。 I tried creating a linked server and using OPENDATASOURCE and OPENROWSET but allways I get the error 我尝试创建一个链接服务器并使用OPENDATASOURCE和OPENROWSET,但总是我收到错误

The OLE DB provider 'Microsoft.ACE.OLEDB.12.0' can not be used for distributed queries because it is configured to run in simple controlled threading mode. OLE DB提供程序“Microsoft.ACE.OLEDB.12.0”不能用于分布式查询,因为它配置为以简单的受控线程模式运行。

I have been searching on internet and I followed all the stepsbut I still have the same error, I have also used SSMS with the Administrator and sa accounts and always the same error. 我一直在互联网上搜索,我按照所有步骤但我仍然有相同的错误,我也使用SSMS与管理员和帐户,并始终相同的错误。 As a curious and strange thing is that after installing the AccessDatabaseEngine 32 "Microsoft.ACE.OLEDB" does not appear in the providers in Server Objects. 一个奇怪和奇怪的是,安装AccessDatabaseEngine 32后,“Microsoft.ACE.OLEDB”没有出现在服务器对象的提供程序中。

Thank you very much and greetings. 非常感谢和问候。

EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'AllowInProcess', 1
EXEC master.dbo.sp_MSset_oledb_prop N'Microsoft.ACE.OLEDB.12.0', N'DynamicParameters', 1
exec sp_configure 'Advanced', 1
RECONFIGURE
GO
exec sp_configure 'Ad Hoc Distributed Queries', 1
RECONFIGURE
GO
exec sp_configure 'xp_cmdshell', 1
RECONFIGURE
GO
sp_configure 'show advanced options', 1
RECONFIGURE
GO
sp_configure 'Ad Hoc Distributed Queries', 1
GO

EXEC sp_addlinkedserver   
   @server = N'DATOS',   
   @provider = N'Microsoft.ACE.OLEDB.12.0',   
   @srvproduct = N'OLE DB Provider for ACE',  
   @datasrc = N'C:\SERVIDOR\DATOS\BBDDs.accdb';  
GO


SELECT id From OpenRowset('Microsoft.ACE.OLEDB.12.0',';Database=C:\SERVIDOR\DATOS\BBDDs.accdb;','SELECT * from Productos') as B
GO

SELECT *  FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source=C:\SERVIDOR\DATOS\BBDDs.accdb')...Productos
GO

Enable the environemnt. 启用environemnt。

EXEC sp_configure 'show advanced options', 1;  
GO  
RECONFIGURE;  
GO  
EXEC sp_configure 'Ad Hoc Distributed Queries', 1;  
GO  
RECONFIGURE;  
GO

Then, check to see if this works. 然后,检查是否有效。

Insert Into database.schema.yourtable SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0',
'Excel 12.0 Xml;HDR=YES;Database=E:\Data\test.xls','SELECT * FROM [sheet1$]');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM