Alteryx Designer Desktop Discussions

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

SQL data pull with custom variables

tahirlone
6 - Meteoroid

I have a text input tool with a two columns named start_date and end_date. The single row contains the values of both variables. 

 

Now I want to pull data from an ODBC driver and in the SQL query, I want to use start_date and end_date values from the text input tool.

 

Any leads will be appreciated

2 REPLIES 2
Hammad_Rashid
11 - Bolide

To use the values of start_date and end_date from the text input tool in your SQL query, you can follow these steps:

  1. Connect the text input tool to the formula tool.
  2. In the formula tool, create a new formula that concatenates start_date and end_date into a single string. For example, if your date columns are in the ‘Date’ format, the formula would look like this: 'SELECT * FROM your_table WHERE date_column BETWEEN ''' + [start_date] + ''' AND ''' + [end_date] + ''';'

This assumes that your SQL syntax requires date values to be enclosed in single quotes. Adjust the syntax based on your database.

  1. Connect the formula tool to the ODBC input tool.
  2. In the ODBC input tool configuration, use the newly created column (containing the SQL query) as the query text.

This should allow you to use the start_date and end_date values from the text input tool in your SQL query. Let me know if you have any other questions or concerns.

harshendra
8 - Asteroid

@tahirlone you can change the Input Data tool to Dynamic Input tool by right clicking on it. Then you can select Modify SQL Query on this Dynamic Input and change variables as required.

 

Dynamic_Input.png

Labels