Select data from an Excel sheet in MSSQL
2007-06-26 00:00
871 查看
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)
相关文章推荐
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- Simple VBScript program to extract data from all worksheets in an Excel spreadsheet
- ASP.NET: Dispaly data from an Excel Spreadsheet
- ASP.NET: Dispaly data from an Excel Spreadsheet
- ASP.NET: Dispaly data from an Excel Spreadsheet
- ASP.NET: Dispaly data from an Excel Spreadsheet
- 在excel中创建sheet的索引 Use index sheets to quickly navigate in an Excel workbook
- How to create an Excel sheet or chart in VC?
- Dynamics AX 2009: Ad hoc Analysis using Excel 2007 to get data from an AX OLAP Cube
- Reporting Services - Export Data to Excel In Only One Sheet
- How to create an Excel sheet or chart in VC?
- using JS to control two select(html),the data can be loaded from database and XML,and show in the select
- a universal class to complete import data from an excel file into a database
- ImportSheet in QTP Data Table from QC
- Import Data from Excel sheet to DB Table through OAF page
- Accessing an Excel Spreadsheet in ASP.NET (VB and
- 【跟着stackoverflow学Pandas】Select rows from a DataFrame based on values in a column -pandas 筛选
- select rows by values in a column from Dataframe
- Updating an Excel spreadsheet from a linked AutoCAD table using .NET
- 直接插入 - An Insecure JSON Data Transference from C# Server Page to Smart Devices Case Share