简体   繁体   English

将数据从SQL Server导出到MS Access

[英]Export data from SQL Server to MS Access

I need to write a stored procedure which reads data from SQL Server and writes it into a MS Access 2003 table. 我需要编写一个存储过程,该存储过程从SQL Server读取数据并将其写入MS Access 2003表中。 I tried the following but it is not working: 我尝试了以下操作,但不起作用:

Insert into OpenRowSet
('Microsoft.Jet.OLEDB.4.0',      
'D:\BEMF_LOAN_RECOVERY.mdb';  
''; -- User ID
'', -- Password
'Select * from access_tbl_name') 
    Select * 
    from sql_server_tbl_name 

Error mesage 错误信息

Msg 7308, Level 16, State 1, Line 2 消息7308,第16级,状态1,第2行
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. OLE DB提供程序'Microsoft.Jet.OLEDB.4.0'不能用于分布式查询,因为该提供程序配置为以单线程单元模式运行。

Are you sure that 'Ad Hoc Distributed Queries' is enabled on your SQL Server? 您确定您的SQL Server上启用了“临时分布式查询”吗?

By default, SQL Server does not allow ad hoc distributed queries using OPENROWSET and OPENDATASOURCE. 默认情况下,SQL Server不允许使用OPENROWSET和OPENDATASOURCE进行临时分布式查询。 When this option is set to 1, SQL Server allows ad hoc access. 当此选项设置为1时,SQL Server允许临时访问。 When this option is not set or is set to 0, SQL Server does not allow ad hoc access. 如果未设置此选项或将其设置为0,则SQL Server不允许临时访问。

https://msdn.microsoft.com/en-us/library/ms187569.aspx https://msdn.microsoft.com/en-us/library/ms187569.aspx

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

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