3

Using MS Office+VBA (or, sometimes, Visual Studio 2010) I am looking for a way to query Excel-Files using only SQL Query, similar to this way of querying a textfile:

SELECT * FROM [Text;DATABASE=L:\Testfiles].test1.csv

As a result I would expect something like:

SELECT * FROM [Excel File=L:\Testfiles\test2.xls].[sheet1$A1:B1000]

I am not looking for a way to query Excel-Files with SQL and a ADODB-connection string (as depicted on connectionstrings.com or here on so.com), since I want all information regarding the data source inside the actual SQL-Code, and not split up between SQL and the connection setup in VB/VBA.

Any hints would be greatly appreciated.

Regards Martin

1 Answer 1

2

You can use FROM clause like this:

FROM [sheet1$A3:E22] IN 'C:\path\MyFile.xlsx' [Excel 12.0;HDR=YES;IMEX=0]
Sign up to request clarification or add additional context in comments.

2 Comments

Excellent. I know I saw something like that before. Many thanks Sergey!
Works perfectly in an Access query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.