# Run SQL Script Task

The *Run SQL Script* task provides flexibility to write SQL code within Astera and execute it as part of a workflow.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FWEDxpqRFdsia5XUGne1Z%2F0.png?alt=media)

To use a *Run SQL Script* task:

1. Drag and drop the *Run SQL Script* task object onto the workflow designer. Configure the object by right-clicking on the object’s header and selecting *Properties* from the context menu.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2Fg8KG6RwCH7mJ4dMSuodE%2F1.png?alt=media)

2. A *Database Connection* window will open, as shown below. This is where we will configure a connection with the database.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F6u6NUgBURz860oK5mEvC%2F2.png?alt=media)

3. To connect to a database, click on the drop-down menu next to the *Data Provider* field and select a data provider from the list.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2FO0fe0kWJeKIayQkUXlex%2F3.png?alt=media)

To establish a connection to a data provider, fill in the credentials such as *User Id*, *Password*, *Server Name*, *Database*, and *Schema*.

The next screen is the *Run Sql Properties* screen.

In the SQL Statement box, enter the SQL code. This code will be executed by the *Run SQL Script* task.

![](https://3891069449-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F28dJIkGHacXhBlux3efx%2Fuploads%2F08g47FP8DCaepgnpg1ak%2F4.png?alt=media)

Once you have added the SQL script, click *OK* to close the window.
