Select data from an Excel sheet in MSSQL

所属分类: 数据库 / 数据库其它 阅读数: 163
收藏 0 赞 0 分享
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) 
更多精彩内容其他人还在看

Select data from an Excel sheet in MSSQL

Select data from an Excel sheet in MSSQL
收藏 0 赞 0 分享

一个多表查询的SQL语句

一个多表查询的SQL语句
收藏 0 赞 0 分享

一个查询的SQL语句请教,希望能够用一条SQL语句得到结果

一个查询的SQL语句请教,希望能够用一条SQL语句得到结果
收藏 0 赞 0 分享

交叉表查询sql语句

交叉表查询sql语句
收藏 0 赞 0 分享

ms SQL server数据库备份、压缩与SQL数据库数据处理的方法

ms SQL server数据库备份、压缩与SQL数据库数据处理的方法
收藏 0 赞 0 分享

DBCC SHRINKDATABASEMS SQL数据库日志压缩方法

DBCC SHRINKDATABASEMS SQL数据库日志压缩方法
收藏 0 赞 0 分享

SQLSERVER 高级复 制 排错 技巧

SQLSERVER 高级复 制 排错 技巧
收藏 0 赞 0 分享

SQL中代替Like语句的另一种写法

SQL中代替Like语句的另一种写法
收藏 0 赞 0 分享

Sql Server下数据库链接的使用方法

Sql Server下数据库链接的使用方法
收藏 0 赞 0 分享

如何取得一个表的所有字段名用逗号分割

如何取得一个表的所有字段名用逗号分割
收藏 0 赞 0 分享
查看更多