# Execute Row SQL Script

The **Execute row SQL script** step executes an SQL statement or file for every input row, allowing you to dynamically assemble SQL for the creation of indexes, partitions, and tables.

{% hint style="info" %}
Prepared SQL statements are not used due to the scripting and dynamic operation of this step, which can slow transformation performance.

For better performance, use dedicated steps like [Table Output](/pdia-data-integration/pdi-transformation-steps-reference-overview/table-output.md), [Table Input](/pdia-data-integration/pdi-transformation-steps-reference-overview/table-input.md), [Update](http://wiki.pentaho.com/display/EAI/Update), and [Delete](/pdia-data-integration/pdi-transformation-steps-reference-overview/delete-step-pdi.md).
{% endhint %}

### General

| Field                       | Description                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
| **Step name**               | Specify the unique name of the Execute row SQL script step on the canvas. You can customize the name or leave it as the default. |
| **Connection**              | Select a database connection.                                                                                                    |
| **Edit**                    | Edit your current database connection.                                                                                           |
| **New**                     | Create a new database connection.                                                                                                |
| **Wizard**                  | Create a new database connection using the wizard.                                                                               |
| **Commit**                  | Number of rows to commit at a time. Default: `1`.                                                                                |
| **Send a single statement** | Clear if you do not want to group rows into a single statement.                                                                  |
| **SQL field name**          | Field that contains either the SQL statement or the path to the SQL file to execute.                                             |
| **Read SQL from file**      | Select if **SQL field name** contains a path to an SQL file.                                                                     |

### Output fields

![Execute Row SQL Script Output Fields](/files/Vxw1xNEfhHWYtyEUF5RG)

The Execute row SQL script step includes the following output field options for collecting statistics about script processing:

| Option                            | Description                                                            |
| --------------------------------- | ---------------------------------------------------------------------- |
| **Field to contain insert stats** | Name of the output field that contains the number of records inserted. |
| **Field to contain update stats** | Name of the output field that contains the number of records updated.  |
| **Field to contain delete stats** | Name of the output field that contains the number of records deleted.  |
| **Field to contain read stats**   | Name of the output field that contains the number of records read.     |

### Metadata injection support

All fields in this step support metadata injection. You can use this step with [ETL metadata injection](/pdia-data-integration/pdi-transformation-steps-reference-overview/etl-metadata-injection.md) to pass metadata to your transformation at runtime.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pentaho.com/pdia-data-integration/pdi-transformation-steps-reference-overview/execute-row-sql-script-cp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
