当前位置: 首页 > 图文教程 > 数据库 > 数据库技巧 > Select data from an Excel sheet in MSSQL

数据库技巧
用计算列实现移动加权平均算法
精通数据库系列之入门-基础篇
精通数据库系列之入门-基础篇2
精通数据库系列之入门-基础篇3
精通数据库系列之入门-技巧篇1
精通数据库系列之入门-技巧篇2
精通数据库系列之入门-技巧篇3
精通数据库系列之入门-技巧篇4
写出高性能SQL语句的35条方法分析
SQL 随机查询 包括(sqlserver,mysql,access等)
在ACCESS和SQL Server下Like 日期类型查询区别
数据库中union 与union all 的区别
修改插入时间不匹配问题
收缩数据库不变小的解决方法
Access和SQL Server里面的SQL语句的不同之处
几种常用DB驱动和DB连接串小结
JDBC大批量写入数据到SQLServer2000,记录数大于10000

数据库技巧 中的 Select data from an Excel sheet in MSSQL


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 132 ::
收藏到网摘: n/a

select *
from openrowset('Microsoft.Jet.OLEDB.4.0'
,'Excel 8.0;HDR=YES;IMEX=1;DATABASE=d:\folder\excel.xls',Sheet1$)
-------NOTE------
Setting IMEX=1 tells the driver to use Import mode. In this state, the registry setting ImportMixedTypes=Text will be noticed. This forces mixed data to be converted to text. For this to work reliably, you may also have to modify the registry setting, TypeGuessRows=8. The ISAM driver by default looks at the first eight rows and from that sampling determines the datatype. If this eight row sampling is all numeric, then setting IMEX=1 will not convert the default datatype to Text; it will remain numeric.
You must be careful that IMEX=1 not be used indiscriminately. This is IMPORT mode, so the results may be unpredictable if you try to do appends or updates of data in this mode.
The possible settings of IMEX are:
0 is Export mode
1 is Import mode
2 is Linked mode (full update capabilities)