SQL读取EXCEL问题
环境:Win2003 / SQL2005 / Office2003
请问上面问题是出在哪里?如何更正?
[解决办法]
1.确认oledb已经安装
2.将代码改成如下试试
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
go
SELECT * INTO spacefield
FROM OpenDataSource
('Microsoft.Jet.OLEDB.4.0','Data Source="D:\temp.xls";Extended properties="Excel 5.0;HDR=Yes;IMEX=1;"')...['sheet1$']
启用Ad Hoc Distributed Queries
--启用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
SELECT * INTO #tmp_asset
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\mswdata.xls', 'SELECT * FROM [sheet1$]') ;
select?*?FROM?OpenDataSource('Microsoft.ACE.OLEDB.12.0',?? ??
?'Data?Source=D:\test.xlsx,Extended?Properties="Excel?12.0;HDR=No;IMEX=1"'),'select * from sheet1'];??