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

数据库技巧
SQL中代替Like语句的另一种写法
Sql Server下数据库链接的使用方法
如何取得一个表的所有字段名用逗号分割
使用SQL Mail收发和自动处理邮件中的扩展存储过程简介
MySQL中的mysqldump命令使用详解
SQL 查询语句积累
SQL server 2005的表分区
关于ADOX的相关知识
如何让SQL运行得更快
ACCESS库转SQLSERVER数据库的注意事项
数据库设计技巧[转]
iwms access与sql版的安装与转换
[转载]让SQL运行得更快
[数据库] 通用分页存储过程
Access数据库升级为SQL数据库的注意事项和方法
Win2003系统安装SQL Sever2000后1433端口未开放的解释
SQL SERVER 与ACCESS、EXCEL的数据转换
Access转MS SqlServer的注意事项
数据库的设计方法、规范与技巧
数据库设计技巧奉送了

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


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