Select data from an Excel sheet in MSSQL
更新時間: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)文章
Navicat?Premium?12.0.29安裝與激活超詳細(xì)教程
這篇文章主要介紹了Navicat?Premium?12.0.29安裝與激活超詳細(xì)教程,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-12-12數(shù)據(jù)庫中的左連接(left join)和右連接(right join)區(qū)別
關(guān)于左連接和右連接總結(jié)性的一句話,左連接 where只影向右表,右連接where只影響左表2012-06-06一條慢SQL導(dǎo)致購物車服務(wù)無法使用的解決方案
今天小編就為大家分享一篇關(guān)于一條慢SQL導(dǎo)致購物車服務(wù)無法使用的解決方案,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12如何利用分析函數(shù)改寫范圍判斷自關(guān)聯(lián)查詢詳解
這篇文章主要給大家介紹了關(guān)于如何利用分析函數(shù)改寫范圍判斷自關(guān)聯(lián)查詢的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用sql具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2018-10-10多種獲取遠(yuǎn)程連接access數(shù)據(jù)庫的方法
多種獲取遠(yuǎn)程連接access數(shù)據(jù)庫的方法...2007-03-03淺談關(guān)系型數(shù)據(jù)庫中的約束及應(yīng)用場景
這篇文章主要介紹了淺談關(guān)系型數(shù)據(jù)庫中的約束及應(yīng)用場景,關(guān)系型數(shù)據(jù)庫是一種廣泛應(yīng)用的數(shù)據(jù)庫類型,它的核心是基于關(guān)系模型的結(jié)構(gòu)化數(shù)據(jù)存儲和管理,在關(guān)系型數(shù)據(jù)庫中,約束是一種重要的概念,它可以幫助我們保證數(shù)據(jù)的完整性和一致性,需要的朋友可以參考下2023-07-07