Select data from an Excel sheet in MSSQL
更新時(shí)間:2007年06月26日 00:00:00 作者:
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)
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)
相關(guān)文章
淺談為什么數(shù)據(jù)庫字段建議設(shè)置為NOT NULL
本文主要介紹了MySQL數(shù)據(jù)庫中將字段設(shè)置為NOT NULL的性能和優(yōu)缺點(diǎn),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2024-12-12
JMeter對(duì)數(shù)據(jù)庫的查詢操作步驟詳解
這篇文章主要詳細(xì)說明,使用JDBC Request組件,如何對(duì)數(shù)據(jù)庫進(jìn)行查詢的各種操作,重點(diǎn)是JMeter中查詢語句的操作步驟,通過實(shí)例代碼講解,需要的朋友可以參考下2021-06-06
sql優(yōu)化實(shí)戰(zhàn) 把full join改為left join +union all(從5分鐘降為10秒)
因?yàn)樘厥庠颍瑹o法訪問客戶的服務(wù)器,沒辦法查看sql的執(zhí)行計(jì)劃、沒辦法知道表中的索引情況,所以,嘗試從語句的改寫上來優(yōu)化2020-09-09
neo4j圖數(shù)據(jù)庫安裝實(shí)踐與報(bào)錯(cuò)問題的解決
這篇文章主要介紹了neo4j圖數(shù)據(jù)庫安裝實(shí)踐與報(bào)錯(cuò)問題的解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
本機(jī)上實(shí)現(xiàn)neo4j遠(yuǎn)程連接方式
這篇文章主要介紹了本機(jī)上實(shí)現(xiàn)neo4j遠(yuǎn)程連接方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2024-02-02
使用Sqlyog遠(yuǎn)程連接數(shù)據(jù)庫報(bào)錯(cuò)解決方案
大家好,本篇文章主要講的是使用Sqlyog遠(yuǎn)程連接數(shù)據(jù)庫報(bào)錯(cuò)解決方案,感興趣的同學(xué)趕快來看一看吧,對(duì)你有幫助的話記得收藏一下,方便下次瀏覽2021-12-12

