ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

[MSSQL] 透过OPENROWSET读取EXCEL

2019-09-16 13:00:44  阅读:375  来源: 互联网

标签:Microsoft OPENROWSET Distributed EXCEL Server OLEDB.4 bit MSSQL


...


STP1. 开启Server>Facets>SurfaceAreaConfiguration>AdHocRemoteQueriesEnabled, 若未开启错误消息如下,

Msg 15281, Level 16, State 1, Line 1
SQL Server blocked access to STATEMENT 'OpenRowset/OpenDatasource' of component 'Ad Hoc Distributed Queries' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'Ad Hoc Distributed Queries' by using sp_configure. For more information about enabling 'Ad Hoc Distributed Queries', see "Surface Area Configuration" in SQL Server Books Online.


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

STP2. MyComputer>Manage>Services>SQLServer(MSSQL)>Properties>LogOn, 以管理员账号密码登入MSSQL, 重启Service, 否则会出现拒绝存取的错误

STP3. 若是32 bit WIN OS + 32 bit Office 2003, 确认Microsoft.Jet.OLEDB.4.0存在Server>ServerObjects>LinkedServers>Providers, OPENROWSET读取EXCEL语法如下,


SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=D:Book1.xls','SELECT * FROM [Sheet1$]')

STP3. 若是64 bit WIN OS + 64 bit Office 2010, 确认Microsoft.ACE.OLEDB.12.0存在Server>ServerObjects>LinkedServers>Providers, OPENROWSET读取EXCEL语法如下,


SELECT * FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=D:Book1.xls', 'SELECT * FROM [Sheet1$]');

TS1. 64 bit OS不支持Microsoft.Jet.OLEDB.4.0, 错误消息如下,

Msg 7308, Level 16, State 1, Line 1
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.

原文:大专栏  [MSSQL] 透过OPENROWSET读取EXCEL



标签:Microsoft,OPENROWSET,Distributed,EXCEL,Server,OLEDB.4,bit,MSSQL
来源: https://www.cnblogs.com/petewell/p/11526765.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有