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

数据库技巧
一条DELETE语句
SQL SERVER 里的错误处理(try catch)
恢复 SQL 被注入后的数据代码
大数据量时提高分页的效率
数据库命名规范小结
where 子句的执行顺序
当数据库变慢时的解决方法
MYSQL 导入数据的几种不同
用户管理的备份(一致性备份、非一致性备份、脱机备份、联机备份)
多条件查询的程序
[原创]access mysql mssql 随机 10条数据的sql语句
Sybase 复制与热切换数据
Sql Server、Access数据排名的实现方法(例如:成绩排名)
sqlserver和oracle中对datetime进行条件查询的一点区别小结
在SQL Server和Oracle中创建job
Linux下 mysql oracle 简单使用手册
sql小计汇总 rollup用法实例分析
连续序号的 sql语句
SQLServer与Access常用SQL函数区别
JDBC 数据库常用连接 链接字符串

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


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