When entering the SQL language for a union query pulling data from an excel workbook what is the correct code to have the union query select data from a specific tab in the excel workbook? Any advice or help is appreciated. Thank you.
Simply use an inline query pointing to external source which the underlying Jet/ACE SQL engine can do for Excel workbooks, Access databases, even text files (txt/csv).
Below assumes Excel workbook is latest format (.xlsx) and begins in A1 cell with defined column headers and same number of columns/types as rest of union query.
SELECT t1.* FROM
myAccessTable t1
UNION ALL
SELECT t2.* FROM
[Excel 12.0 Xml;HDR=Yes;Database=C:\Path\To\Excel\Workbook.xlsx].[mySheetName$] t2
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.