Database Run Query Activity

I have to insert few values to a database table. For that I’m using assign activity to assign the values to required variables.

How can I insert variable values into database using run query activity.

Kindly help

@Aarya_Sajeev

For insert you need to use run non query and in the insert statement include variables

Cheers

Hi @Aarya_Sajeev ,
Database connect.docx (205.0 KB)

Pls check this doc for detailed connection of db and run query.

Inserting data to database requires couple of steps. Kindly follow the below steps and let us know where exactly you are facing challenge

  1. Assign the values to the required variables using the Assign activity.
  2. Use the Connect activity from the UiPath.Database.Activities package to establish a connection to your database.
  3. Create an SQL insert query string that includes the variable values.
  4. Use the Run Query activity to execute the SQL insert query.

For example, if you have variables for name and phone number, your SQL query might look like this:

"INSERT INTO YourTableName (NameColumn, PhoneColumn) VALUES ('" + nameVariable + "', '" + phoneVariable + "')"
  1. Finally, use the Disconnect activity to close the database connection.

This process allows you to insert variable values into a database table using the Run Query activity in UiPath

1 Like