Creating Variables From a DB column

If I have a datatable with a columns named “OutputVariables” and “Values” , is there a way to loop through the table and declare a variable for each item in the OutputVariables column? The variable name would be what is in the “OutputVariables” column and the value would be in the “Values” column.

Hi @travis.bass

It’s not possible to create a variable with the OutputVariables column and assign values frm the Values column. This not works here.

Instead of this create a Dictionary Collection variable. Then iterate the each row using for each row in datatable activity. Keep the OutputVariables column values as key and Values column values as value to the key. By using dictionary you can call the value with OutputVariable column value easily.

Hope it helps!!

@travis.bass

Dynamically creating variables is generally not considered a best practice, the alternative approach is to store the values in a dictionary.

HAPPY AUTOMATION!!

Hello @mkankatala , So what I am trying to do is get the results of multiple SQL queries. I am using the Run Query activity over and over again. I am looking for a way to make the code cleaner and instead of using the activity multiple times I want to loop through a list of queries and store them to a Datatable variable. The issue is for the Output I need to pass in a Datatable variable. I am getting a compiler error when I try to use the dictionary value.