Let’s talk Alteryx Copilot. Join the live AMA event to connect with the Alteryx team, ask questions, and hear how others are exploring what Copilot can do. Have Copilot questions? Ask here!
Start Free Trial

Alteryx Designer Desktop Discussions

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

Passing the workflow constant to SQL Query "from" statement

tamluenwai29
8 - Asteroid

Dear All, 

 

I have created a workflow constant and named it to "Parameter", and the value of this constant I have defined to "completion".

 

I am trying to pass this value to SQL query in the from statement, but I got a syntax error.

Can someone give me some advice on it? Thanks a lot!!

pic1.png

I would like to perform something like this, which implies when I update the workflow constant the query result will be changed. 

 

i.e.,

Workflow constant= "ABC"

select * from dbo.vw_iPM_inform_ABC

 

Workflow constant = "211"

select * from dbo.vw_iPM_inform_211

p2.png

3 REPLIES 3
Yoshiro_Fujimori
15 - Aurora
15 - Aurora

@tamluenwai29 ,

 

I understand SQL in Input Data Tool is passed to the database as it is.

To update a specific string in SQL dynamically, I would pass it via Control Parameter Tool.

 

Sample SQL

select Column1, Column2
from [YourTable]
where Column2 = '%Param%'
 
And update the string %Param% with the data from Control Parameter Tool with Action Tool.
1274499_ActionTool.png1274499_Macro.png
 
I hope this helps.
tamluenwai29
8 - Asteroid

Hi, 

Thanks for your reply. But I would like to know is there any other methods to perform the same task except using macros? Thanks!

Matt_D
10 - Fireball

Hi @tamluenwai29 

 

If you want to go down the route of changing workflow constants, and updating the SQL without a macro you could just have your parameter and query in a text table, use a filter tool to filter by the constant and then dynamically update the SQL clause.

 

Capture.PNG

 

If the query is static apart from the end value, you could just use a formula tool to update the query instead

 

Capture.PNG

 

Thanks,

 

Matt

Labels
Top Solution Authors