0

I receive the following error message for my SQL statement and I cannot find the error: "An error occurred while checking the query syntax. Errors: Invalid column name 'Opt'

This was a quite similar problem, however it did not help me to solve my problem. Marketing Cloud SQL - Invalid Column Name

Does anyone has a solution for me. What did I do wrong? The SQL statement is:

I.PlayerID, M.Opt-In_Mail, S.Opt-in_SMS
from
ContactableUsers_MultiBetslip_20201110 as I
inner join 
MasterData_Email as M on I.PlayerID = M.ID
inner join 
MasterData_SMS as S on I.PlayerID = S.ID
2
  • Please add the data extension structure in your question. Also, can't see the select in your query, must be a typo :) Commented Nov 13, 2020 at 11:27
  • Oh yes, before the first row the select missing. But that was definitely there. The structure of the date extension that shall be filled is: PlayerID - Opt-In_Mail - Opt-in_SMS The Data Extensions from which the data shall be taken have these information and a lot more.
    – Bianca
    Commented Nov 13, 2020 at 11:55

1 Answer 1

6

The problem is that SQL has trouble with the - in a field name. Just make sure it understands it by wrapping the fieldname in brackets. In general, just don't use "-" in fieldnames and it won't happen again :)

this works:

S.[Opt-in_SMS]

Not saying that Query Studio is to be trusted verbatim, but it can help sometimes. Query studio's highlighter shows this behavior, you see it interprets everything following the "-" as something other than the fieldname. This query fails like yours.

enter image description here

fixed (and this query works):

enter image description here

2
  • It worked out :) Thank you for your help!
    – Bianca
    Commented Nov 13, 2020 at 12:26
  • To add to Jonas' answer, if you need to split a word use an underscore '_' (eg: opt_in). You won't have any issues that way.
    – Rainer G
    Commented Nov 15, 2020 at 22:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .