在sql查询编辑器中执行 启用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 Table08
FROM OpenDataSource
('Microsoft.Jet.OLEDB.4.0','Data Source="E:\1.xls";Extended properties="Excel 5.0;HDR=Yes;IMEX=1;"')...[Sheet1$]
Table08:表名要新名称
E:\1.xls:源文件
Sheet1:excel中的表名
sql在导入时,以数据的第一行判断字段类型,如果是混合型字段(文字、数字),要把有代表型的行调整到第一行。这样就不会出现null了