# 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.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FgxZUnfFZieZzB7Kjsodu%2Fimage.png?alt=media&#x26;token=c7522ba1-8f66-478e-a44b-01cbdfcf1eb4" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FETrkHLqZL11vs3Q3693N%2Fimage.png?alt=media&#x26;token=1b40995c-1ec0-4c58-97df-1415929c40cd" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FFtDCwcHVSupInccj1BCz%2Fimage.png?alt=media&#x26;token=607227a1-898e-4fb3-9d2b-0e163756a6c4" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FXgJSYQHav1sFJEa549ki%2Fimage.png?alt=media&#x26;token=0c4c0d13-3a50-4aa6-85e8-3657630232b2" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://750977703-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqHxyVNGb7tSdIWecl6Ru%2Fuploads%2FJ6QY5WXCNV9l7WhrOOCS%2Fimage.png?alt=media&#x26;token=a8a4b4e5-130f-48eb-942b-d9445e9f0002" alt=""><figcaption></figcaption></figure>

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