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

数据库技巧
一个查询的SQL语句请教,希望能够用一条SQL语句得到结果
交叉表查询sql语句
ms SQL server数据库备份、压缩与SQL数据库数据处理的方法
DBCC SHRINKDATABASEMS SQL数据库日志压缩方法
SQLSERVER 高级复 制 排错 技巧
识别 MS SQL 各个版本的版本号的方法
数据库查询中遭遇特殊字符导致问题的解决方法
替换一个字段的所有非数字字符为空的sql语句
用SQL Server访问Sybase中的表的方法
掌握SQL Server数据库快照的工作原理
mssql 区分大小写的详细说明
Sybase数据库sa密码丢失后解决方法
特殊的存储过程-触发器概述
MSSQL内连接inner join查询方法
很全的SQL中文解释代码
SQL Server不存在或访问被拒绝问题的解决
比较实用SQL语句总结
SQL SERVER的字段类型说明
sql server中datetime字段去除时间代码收藏
Access转换成SQL Server需要注意事项整理

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


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