# Run SQL Script

{% embed url="<https://youtu.be/j_9UQb2ipws?si=Vpg8AOz28dCz5NdA>" %}

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

<figure><img src="https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FiJgBc5FlpEptD0Tsdqwj%2F01-Run-SQL-Script-Object.PNG?alt=media&#x26;token=79d34919-b851-4fe6-945c-2ce20712fe76" alt=""><figcaption></figcaption></figure>

To use a *Run SQL Script* task, 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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FSZtpgV0ViKoLJ1rSt5K6%2F02-Run-SQL-Script-Click.PNG?alt=media\&token=9ef83d7e-419d-4c91-84c1-90a681b3cb73)

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

![](https://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FUIqI1AtphfTd4KFJFgtL%2F03-Run-SQL-Script-DB-Conn.PNG?alt=media\&token=1fb92e18-bd9b-45f9-ac32-9170be0da41d)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FhFwpie0UHnm09c9Jijmb%2F04-Run-SQL-Script-Properties.PNG?alt=media\&token=6c872ed1-02eb-40b6-b4ab-9f57fcd12959)

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://3083465318-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsR50Wa7EwZGlmPSAMkkf%2Fuploads%2FCqwAYUhDHqT8ilYDK3vj%2F05-SQL-Script-DB-Conn-Options.png?alt=media\&token=af77af3a-de64-4d44-be5e-b876bd365706)

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

This concludes the working of the *Run SQL Script* object in Astera.
