Using parameter in SQL statement
- 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'm currently extracting data from a Teradata database via ODBC connection and SQL statements. I would like to added a parameter to Alteryx workflow that is used as part of the SQL being through. e.g
Select A.Field1, A.Field2
From DB.Table A
Where A.Field1 in (‘parameter’, ‘parameter’)
Any advice on how to do this?
Solved! Go to Solution.
- Labels:
- Database Connection
- Preparation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
The Dynamic Input tool is what you are looking for. It allows you to modidy a SQL Query based on fields in your Alteryx data stream.
In the tool configuration you will see a dropdown menu 'Add'. One of the options is 'SQL: Update WHERE Clause'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
You could have the Input tool containing the SELECT statement as a macro and set up a Control Parameter and Action to pass in the parameter values, replacing the specific string in the select statement. Something like in the attached screenshot (I can't upload into this post for some reason...so had to put into a word doc)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the quick responses!
Both solutions logically make sense so will give them both a go and see which feel more comfortable with.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks for the input. I tried using this logic and it holds for where clause having one parameter. what if have multiple parameter to select/input different values each run? when ever I use the dynamic input tool and the pop up window shows only one of the clause used in where condition.
Ex: Products to choose from, date filters to choose from, categories to choose from.
Looking forward.
