Run Query
UiPath.Database.Activities.ExecuteQuery
Description
Executes a query on a database and returns the query result as a DataTable.
Project compatibility
Windows - Legacy | Windows | Cross-platform
Windows - Legacy, Windows configuration
Designer panel
- Configure Connection... - Select an existing database connection or add a new one using the Connection Wizard.
- SQL query - An SQL command to be executed. This field must be completed according to the selection from the Command type property. This field supports only
Stringvariables.
Properties panel
Common
- Continue on error - Specifies if the automation should continue even when the activity throws an error. This field only supports
Booleanvalues (True, False). The default value is False. As a result, if the field is blank and an error is thrown, the execution of the project stops. If the value is set to True, the execution of the project continues regardless of any error.noteIf this activity is included in Try Catch and the value of the Continue on error property is True, no error is caught when the project is executed.
- DisplayName - The display name of the activity. This field supports only
Stringvariables. - Timeout - Specifies the amount of time (in millisecond) to wait for the SQL command to run before an error is thrown. The default value is 30000 milliseconds (30 seconds) and must be greater than or equal to 0. This field supports only
Int32variables.noteThe amount of time specified in this field does not include the response time for the query result retrieval. This means that the total execution time of the activity may be greater than the actual query execution time, to which the TimeoutMS property applies.
Connection Configuration
- Connection string - The connection string used to establish a database connection. This field supports only
Stringvariables. - Existing connection - An already opened database connection obtained from the Connect or Start Transaction activities. If such a connection is provided, the
ConnectionStringandSecureConnectionStringproperties are ignored. This field supports onlyDatabaseConnectionvariables. - Provider Name - The name of the database provider used to access the database. This field supports only
Stringvariables. - Secure connection string - The connection string used to establish a database connection as Secure String. This field supports only
SecureStringvariables.
Input
- Parameters - A dictionary of named parameters that are bound to the SQL command. The binding is done by specifying the
@parameterNamestatement in the SQL command. At runtime the parameterName is replaced with its value from the dictionary. - SQL query - An SQL command to be executed. This field must be completed according to the selection from the Command type property. This field supports only
Stringvariables.
Misc
- Command type - Specifies how a command string is interpreted. The following options are available:
- Text - Executes the query given in the SQL parameter.
- StoredProcedure - Invokes the procedure name specified in the SQL parameter.
- TableDirect - Invokes all records from a table.
- Private - If selected, the values of variables and arguments are no longer logged at Verbose level.
Output
- Data table - The output of the SQL command wrapped in a
DataTablevariable.noteWhen you query a table that has columns with
Datedata type, the corresponding columns in the outputDataTableare going to be ofDateTimedata type.
Cross-platform configuration
- Existing connection - An already opened database connection obtained from the Connect to database activity.
- Command type - Specifies how a query string is interpreted. The following options are available:
- Text - Executes the SQL command.
- Stored Procedure - Invokes the procedure name specified in the SQL command.
- Table Direct - Invokes all records from a table.
- SQL query - An SQL command to be executed. This property must be completed according to the selection from the Command type property.
Advanced options
Other
- Parameters - A dictionary of named parameters that are bound to the SQL command. The binding is done by specifying the
@parameterNamestatement in the SQL command. At runtime, the parameterName is replaced with its value from the dictionary. - Timeout - Specifies the amount of time (in milliseconds) to wait for the activity to perform the task before an error is thrown. The default value is 30000 milliseconds (30 seconds). The timeout value must be greater than or equal to 0.
- Continue on error - Specifies if the automation should continue even when the activity throws an error.
Output
- Data table - The output of the SQL command wrapped in a
DataTablevariable.