Execute SQL queries to Microsoft Excel
Excel files consist of one or more Worksheets. A Worksheet can be treated as an SQL Table.
Take a look at the following sample queries. The relevant Excel file is attached below.
- SELECT * FROM [Students$];
Students represents a Worksheet's Name within the selected file. It needs to be followed by the $ symbol and be included in square brackets.
- SELECT [Full Name] FROM [Students$] WHERE [Student ID] =1;
Our Columns, Full Name and Student ID, need to be included in square brackets.
- INSERT INTO [Books$] ([Book Name], [Book ID]) VALUES ('The Odyssey', 4);
Books represents the file's second Worksheet.
- UPDATE [Students$] SET [Full Name] = 'Leonardo N' WHERE [Student ID] = 3;