Select data from an Excel sheet in MSSQL

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.