How To Pass Dynamic Data To SQL Query From UiPath?

« Go Back


Article Number000002550
TitleHow To Pass Dynamic Data To SQL Query From UiPath?
URL NameHow-to-pass-dynamic-data-to-SQL-query-from-UiPath
Product ComponentStudio
Sub ComponentActivities_Database
Studio VersionAll
Orchestrator VersionN/A
QuestionHow to pass dynamic data to SQL query from UiPath ?
Issue Description + Resolution
Pass dynamic data to SQL query, by following any of the below methods
  1. Passing variable to SQL query
  2. Passing parameter to SQL query

Approach #1: Passing Variable To SQL Query
  1. In order to pass variables to SQL query, variables must be declared first. In the below screenshot, three variables are declared and assigned values using assign activity before doing any SQL operation.
  1. The SQL query(INSERT/UPDATE/SELECT) needs to be modified to have those variable names as below. This can be done by clicking "Edit Query" option.
"INSERT INTO [dbo].[Table4] (Name,Value,Description)
VALUES ('"+Var_Name+"','"+Var_Value+"','"+Var_Description+"')"


Approach #2 : Passing Parameter To SQL Query

  1. The best way to pass the dynamic values to a SQL query is by using parameters. In order to use this option, click on "Edit query" in "Execute Query" or "Execute nonquery" activity.
  2. Click on the Parameters property in the Input section and pass the parameters. Refer the below screenshot.


  1. Enter the Arguments name. The arguments name need not match with the variables created, and then select the variable type.
  1. In the value section, enter the variable name because value of the variable will be accessed through the variable itself. Enter the name of the variable in the Value section.
  1. Next, the three parameters need to be passed in the query(Argument1, Argument2, Argument3), which are nothing but the Name of the parameters in the first column. 
  2. By adding @ symbol as a prefix in each argument name as shown below, these parameters can be passed in the query. Refer the below screenshot.


Last Published Date9/23/2022 5:03 PM