Alteryx Designer Desktop Discussions

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

Create Post SQL Statement based of formula?

Hamder83
11 - Bolide

Hi 

I'm using the same flow for several different sources.

For all of them I wanna define the source and use this to create my sql table:

But I also wanna define a primary key, and the only way I found is this. But can the post create sql statement use a formula field?

ALTER TABLE UNIFY_DK_CONSOLIDATED <-- replased with formla field?
ALTER COLUMN ID int NOT NULL;

ALTER TABLE UNIFY_DK_CONSOLIDATED

ADD PRIMARY KEY (ID);



3 REPLIES 3
mceleavey
17 - Castor
17 - Castor

Hi @Hamder83 ,

 

The easiest way to do this is to put the output tool in a macro and feed the SQL script in as a control parameter. This control parameter can connect to eh output tool in the macro with the Action tool updating the value in the Post SQL Script field, or the specific variable within the script.

So, you could create the dynamic variable, in this example "UNIFY_DK_CONSOLIDATED " as a formula, take a sum of this grouping by this field and feeding in as the control parameter. In your script, change this value to be XXXXX and have the action tool overwrite that value.

This means you can dynamically create the SQL script.

 

Hope this helps.

 

M.



Bulien

apathetichell
18 - Pollux

Here's an illustration for how it would work with Pre - Post would be the tactic.

 

https://community.alteryx.com/t5/Alteryx-Designer-Discussions/Using-constant-in-output-tool-presql-s...

Hamder83
11 - Bolide

Hi Both of you

It seems like you have the same approcah. so i'm sorry for my lack of skills. 

I have attaced my small sample workflow with the macro linked too, after i changed it to post sql.

But there most be something obvious im missing?

 

 

Labels