在给SQL 2005导入Excel数据库,语句如下:
SELECT * into dbtable
FROM OPENDATASOURCE(''Microsoft.Jet.OLEDB.4.0'',
''Data Source=c:\book1.xls;User ID=Adminassword=;Extended properties="Excel 8.0;HDR=Yes;"ersist Security Info=False'')...[Sheet1$]
然后提示出错
SQL Server 阻止了对组件 ''Ad Hoc Distributed Queries'' 的 STATEMENT''OpenRowset/OpenDatasource'' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 ''Ad Hoc Distributed Queries''。有关启用 ''Ad Hoc Distributed Queries'' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。
解决方法:
因为SQL2005默认是没有开启''Ad Hoc Distributed Queries'' 组件,开启方法有两种,如下:
1、USE master;
GO
EXEC sp_configure ''Ad Hoc Distributed Queries'', ''1'';
RECONFIGURE;
EXEC sp_configure; 2、在SQL Server 配置工具---SQL SERVER 外围应用配置器----功能的外围应用配置器 如下图
|