' ' is not a valid name - SQL in Excel

Padawan018

Board Regular
Joined
Sep 29, 2006
Messages
63
I am receiving this error when trying to convert an SAP data dump to a recordset in Excel via SQL. I have the named range set to the exact area so I don't have any extra columns.

Any help would be greatly appreciated.

Thanks
__________________
Don't feed my insanity!
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Hi, Padawan. Suggest you post the SQL. Maybe check all the headers first; and if the SQL doesn't reflect them correctly, post relevant information. F
 
Upvote 0
Hi Fazza,

After importing the Excel data into Access I was able to determine that one of the headers contained periods. I removed the periods and the code worked beautifully. I am new to using SQL in Excel so I am still learning some of syntax issues.

Thanks,
Padawan018
 
Upvote 0
Good work, Padawan.

The period is the standard separator between table & field names. Such as,

Code:
SELECT MyTable.MyField, MyTable.AnotherField
FROM MyTable

So, the problems with a period within the field name are obvious. Usually with problematic characters, enclose the whole field name `like this`.

Also, enclose text 'like this'. Such as, untested

Code:
SELECT TOP 10 M.MyField, M.AnotherField, Sum(M.Value) AS [Cost]
FROM MyTable M
WHERE M.MyField Like '%bank%' AND M.ID_Num > 100
GROUP BY M.MyField, M.AnotherField
HAVING Sum(M.Value) > 10000
ORDER BY Sum(M.Value) DESC

HTH, Fazza
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,853
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top