0

I am trying to get the email addresses of all subscribers of a specific Auto Suppression list. However, the issue is that the name of the column containing email addresses has a space i.e "Email Address". I tried the below query with no luck:

SELECT [Email Address] as Email
FROM LIST_NAME

I get the error: Error saving the Query field.Incorrect syntax near '('.

To test my hypothesis that using square brackets to select a column containing a space was causing the issue, I added a new column to the auto suppression list called "Test" and was able to successfully query the list with the below query:

SELECT Test
from LIST_NAME

However, when I attempted this query:

SELECT [Test]
from LIST_NAME

I got the same error message as above (Error saving the Query field.Incorrect syntax near '('.)

But, when I put the square brackets around the list name and NOT around column name in the SELECT clause:

SELECT Test
from [LIST_NAME]

the query worked fine.

So it must be something to do with using square brackets around column names in the SELECT clause? If this is true, how do you handle spaces in column names?

Any help is appreciated!

  • Try double quote around it. stackoverflow.com/questions/2901453/… – Gortonington Mar 10 at 23:26
  • @Gortonington It works for "Test" but when I try "Email Address" I get "Error saving the Query field.Incorrect syntax near 'Address'." – MarketingCloudNoob Mar 11 at 2:06
  • I've already faced the exact same problem with Query Studio. Finally, I ended up creating a query activity and runing it in Automation Studio. It worked fine. – Rachid Mamai Mar 11 at 9:16
  • Have you tried single quotation marks? – Eliot Harper Mar 11 at 9:49
1

Query Studio seems to run into this issue when you do not use an alias for the table.

Try this:

SELECT l.[Email Address] as Email
FROM LIST_NAME l
| improve this answer | |
0

I always get the same error when the first field in the select statement have square brackets, this is some issue with Query Studio. Get another field as the first field, and just ignore it, or "set a dummy" field as the first one:

Select
  'ignore' as dummy,
   [Email Address] as Email
FROM LIST_NAME
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.