有挑战问题:在Sql Server2005的查询分析器中执行下列Sql语句,为什么一台机器上可以,一台机器上不行?
CREATE TABLE [dbo].[Table_1](
[Y1] [char](4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[M1] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[D1] [char](2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
insert into Table_1(Y1,M1,D1)
select * from OPENROWSET( 'MICROSOFT.JET.OLEDB.4.0 ', 'Excel 8.0;HDR=YES;IMEX=0;DATABASE=C:\a.xls ', 'select Year(F6),Month(F6),Day(F6) from [a, Payroll Report$] where F6 is not null ')
Select * from Table_1
提示错误:
OLE DB provider "MICROSOFT.JET.OLEDB.4.0 " for linked server "(null) " returned message "Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done. ".
OLE DB provider "MICROSOFT.JET.OLEDB.4.0 " for linked server "(null) " returned message "Data type mismatch in criteria expression. ".
OLE DB provider "MICROSOFT.JET.OLEDB.4.0 " for linked server "(null) " returned message "Data type mismatch in criteria expression. ".
OLE DB provider "MICROSOFT.JET.OLEDB.4.0 " for linked server "(null) " returned message "Data type mismatch in criteria expression. ".
Msg 7346, Level 16, State 2, Line 10
Cannot get the data of the row from the OLE DB provider "MICROSOFT.JET.OLEDB.4.0 " for linked server "(null) ". The provider cannot determine the value for this column.
------解决方案--------------------以上SQL使用的是当前查询分析器连接的数据库服务器上的excel文件,确认后一台服务器上安装了OFFICE。
------解决方案--------------------而且excel文件要求在本地
不再本地的不可以
------解决方案--------------------确认正在使用的数据库服务器上安装了Office组件,并且在相应目录下存在指定文件。
------解决方案--------------------打开 配置工具 -> 外围应用配置器 -> 功能的外围应用配置器 -> 即席远程查询 -> 选中启用openrowset 和 opendatasource 支持