Declaring Variables in SQL Editor - Is it Possible?
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
I really need to be able to DECLARE/SET variables in the SQL Editor in the INPUT tool. I've only found "Use the Alteryx GUI Instead" as an option in the community fora, but that is not an acceptable option for me since my SQL code sets are used both with and without Alteryx.
Is there any syntax I can use that will allow me to implement this type of SQL command in Alteryx?
DECLARE @Start AS DATE;
SET @Start = '1/1/2023';
- Labels:
- Input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @Mitch_S
Can you provide more information about what your doing with @Start variable in your SQL. With more info, we might be able to come up with a work around. I have a feeling that using a Dynamic Input tool and replacing parts of the template string might the way to go, but I can't be sure without some details of your use case.
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey danilang,
Here is are some variables I routinely set.
DECLARE
@Reporting_Period VARCHAR(254)
,@Start_Date DATETIME
,@End_Date DATETIME
,@SA VARCHAR(4);
SET @SA = '158'
SET @Reporting_Period = 'Use Custom Period'
SET @Start_Date = '6/01/2012'
SET @End_Date = '5/31/2013';
