日期:2014-05-17  浏览次数:20397 次

将本地的一个excel插入到数据库表中出现错误,求高手指导啊!!
SELECT 数据.excel into LIST
FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0',
  'Data Source="C:\Users\Rich\Desktop')...xactions
这是数据库插入语句,这有什么错误吗?我是想将桌面上名为 数据.excel的文件插入到数据库中名为LIST的表中。
这是错误提示:
消息 15281,级别 16,状态 1,第 1 行
SQL Server 阻止了对组件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的访问,因为此组件已作为此服务器安全配置的一部分而被关闭。系统管理员可以通过使用 sp_configure 启用 'Ad Hoc Distributed Queries'。有关启用 'Ad Hoc Distributed Queries' 的详细信息,请参阅 SQL Server 联机丛书中的 "外围应用配置器"。
 

或者哪位高手知道怎么将excel中的数据导入到数据库表中。
数据库 excel

------解决方案--------------------
--启用Ad Hoc Distributed Queries 即可: 
exec sp_configure 'show advanced options',1 
reconfigure 
exec sp_configure 'Ad Hoc Distributed Queries',1 
reconfigure 
    

--用完关闭:Ad Hoc Distributed Queries: 
exec sp_configure 'Ad Hoc Distributed Queries',0 
reconfigure 
exec sp_configure 'show advanced options',0 
reconfigure

------解决方案--------------------
--#2.调用OPENROWSET查询
--打开高级选项,允许即席查询
EXEC SP_CONFIGURE 'show advanced options',1  
RECONFIGURE  
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries',1  
RECONFIGURE
GO

SELECT *
FROM OPENROWSET
(
'SQLOLEDB',
'SERVER=127.0.0.1,1433,port;uid=xx;pwd=xxxxx;Database=master',
'SET FMTONLY OFF;SET NOCOUNT ON; EXEC distribution.sys.sp_MSenum_distribution'  --调用存储过程 
) T
WHERE T.[status] > 4
ORDER BY [status]

--关闭选项
EXEC SP_CONFIGURE 'Ad Hoc Distributed Queries',0
RECONFIGURE
EXEC SP_CONFIGURE 'show advanced options',0  
RECONFIGURE
GO