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

数据库技巧
执行Insert Exec时的隐藏开销 分析
datastage server job之dsjob 命令
sql Union和Union All的使用方法
对分区表进行alter-switch时遇到的错误
sql left join 命令详解
sql 插入数据的三种常用方法及小贴士
SQL 优化经验总结34条
数据库 SQL千万级数据规模处理概要
数据库分页查询方法
postgres 数据库中的数据转换
ORACLE 系统函数大全SQLSERVER系统函数的异同
数据库 三范式最简单最易记的解释
主键与聚集索引
数据库触发器(Trigger)的一点使用心得
postgresql sql批量更新记录
sql join on 用法
SQL 按特定字段值排序
jdbc 数据库的连接(sqlserver oracle)
让你的insert操作速度增加1000倍的方法
数据库 关系连接

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 133 ::
收藏到网摘: 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)