0

Some of our Data Extention names and the fields within those names have characters that makes it impossible for me to query. Is there a way to escape these characters and allow me to query and get results?

The error I get is: "Error saving the Query field.Incorrect syntax near 'CampaignMember:'"

Query Example:

SELECT CampaignMember:Common:Email
FROM [Email Journey - 2021-03-22]

Data Extension Name: Email Journey - 2021-03-22

Fields:

  • CampaignMember:Id
  • CampaignMember:Common:Email
  • MemberRecordType
Martin
  • 15
  • 2
  • 7

2 Answers2

1

I was able to get it to work by using square brackets and aliasing the table. Example:

SELECT t.[CampaignMember:Common:Email] 
FROM [Email Journey - 2021-03-22] t
Meshel
  • 11
  • 2
0

As I wrote in my comment above you can put your column names between square brackets like this:

SELECT [CampaignMember:Common:Email]
FROM [Email Journey - 2021-03-22]

More info about using the square brackets: https://stackoverflow.com/a/52901/20126

Also worth mentioning you can also use Single or double quotation: https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2008-r2/ms176027(v=sql.105)?redirectedfrom=MSDN

Amr Elgarhy
  • 66,568
  • 69
  • 184
  • 301
  • Thanks for the response. I tried that as well. This is the query: SELECT [CampaignMember:Common:Email] FROM [Primary Email Journey - 2021-03-22] I now get this error: Error saving the Query field.Incorrect syntax near '('. – Martin Jun 11 '21 at 20:31
  • and this error is happening on this query line or is there any SQL statements you are running with this one? – Amr Elgarhy Jun 11 '21 at 21:42
  • Nope, this is the only query. Could it be because "Primary" is a keyword in SQL? – Martin Jun 15 '21 at 19:46
  • What I know that the square bracket will work even if a keyword is used inside. – Amr Elgarhy Jun 15 '21 at 21:02