In case you missed the announcement: Alteryx One is here, and so is the Spring Release! Learn more about these new and exciting releases here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Alteryx SQL Editor adding spaces before and after dashes

NawfalMahmood
5 - Atom

Hello everyone,

 

I am copying a previously opened thread, since I am encountering the exact the same issue, I just updated the version of Alteryx Desktop, the link is provided below:

 

Alteryx changes my sql code by adding spaces before and after dash/hypen.

 

Step 1 I put this functioning workflow into the SQL Editor:

Select *

from `alpha-data-main-bfg.D6_FACT_MAC.WJ_BT_APPLES`

(works great)

 

Step 2.  Click on the Visual Query Builder and add/remove columns / change anything.   

Then click back on SQL Editor and my code has changed to 

Select *

from `alpha - data - main - bfg.D6_FACT_MAC.WJ_BT_APPLES`

(spaces added before and after dashes)

 

Now my query won't run and gives error messages indicating that the data source doesn't exist.  

So i have to go back in and find/replace to remove the spaces Alteryx added. 

 

Is this a known problem with a solution? 

I'm on Version: 2021.3.4.00445

 

Previous thread: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Alteryx-SQL-Editor-adding-spac...

 

7 REPLIES 7
rzdodson
12 - Quasar

@NawfalMahmood from what I am tracking to, I encounter similar issues as well. I typically utilize Microsoft SQL Server Management Studio to write the preponderance of my SQL query, and then copying and pasting it in to an Input or In-DB tool afterwards. It staves off Alteryx's Query builder from adding or removing underscores from the query language and enables it to run without issue.

apathetichell
19 - Altair

I do this via text input tool and dynamic input in-db (usually in a batch macro with some changing parameter) but same idea... 

NawfalMahmood
5 - Atom

Thank you for sharing your experience. Unfortunately, I dont utilize Microsoft SQL Server Management Studio. I am hoping to find a fix within Alteryx, not sure if this is a bug or there is a reason behind it.

NawfalMahmood
5 - Atom

Thank you for sharing your experience. I am not using in-db tool, hopefully there is a solution for regular data input tool.

rzdodson
12 - Quasar

@NawfalMahmood I hate to be the bearer of bad news, but that is just how the SQL Query Builder is. If you must use it (i.e. the organization does not have a data dictionary which tells you what fields are what) then use the Query Builder. Then, once you have selected all of your fields, copy/paste that over to some word processor (Word, Notepad) and then change the table name through a CTRL+F + Replace. Once the query is converted to what it ought to be, you can copy/paste it back in your query builder window. Once that restructured query is loaded, your workflow should run without issues.

Feastie
7 - Meteor

Hi all,

I am having a similar issue with spaces being added to code, resulting in an error.

My code works at first:

 

"AND  TMP1.[Row_Num] = (SELECT TMP1.[Row_Num]-2
FROM TMP1
WHERE TMP1.[Date] = CAST(GETDATE() as DATE))"

 

but, if you open the editor, it changes to:

 

"AND  TMP1.[Row_Num] = (SELECT TMP1.[Row_Num] - 2
FROM TMP1
WHERE TMP1.[Date] = CAST(GETDATE() as DATE))"

 

All that changes, are the additional spaces of the minus two.

This however, results in the code not working.

I have tried putting brackets around various parts, but the same happens.

Any thoughts??

Thanks, Phil.

Feastie
7 - Meteor

Obviously this is part of a larger code sequence!

Labels
Top Solution Authors