# Using SQL with Excel

There are some slight peculiarities with using SQL with Excel.

You may use an Excel worksheet or a named range as an SQL table. However, if you use a worksheet, you MUST add a "$" character to the end of the worksheet name. If you use a named range, you do not need to add the "$".

For example, if you are importing an Excel document that has a worksheet called "Sheet1", you MUST refer to it as "Sheet1$". If you click the Browse button next to the table name field, it will show you the correct names for each of the sheets and named ranges in the file.

The second rule is that you MUST use a "`" character around the name of either a worksheet or a named range when constructing an SQL statement. For example:

SELECT * FROM `Sheet1$`

The following will NOT work:

SELECT * FROM Sheet1

Please note that the character is a "backwards quote", not a standard single quote (') character. The backwards quote is normally found top left on your keyboard.

You can use joins between tables with an Excel source. For example, the following SQL statement:

SELECT newContacts$.*, newDetails$.*

FROM `newContacts$` INNER JOIN `newDetails$`

ON newContacts$.AccountNo = newDetails$.AcntId;

will join together the contents of the newCnntacts and the newDetails worksheets from the Inaport_Examples.xls example file.