# Execute SQL Script to Read Data

Source: [https://docs.virtosoftware.com/docs/virto-workflow-automation-web-part/virto-sharepoint-workflow-activities-kit-sharepoint-2010-workflow-platform/database-activities/sql-script-to-read-data/](https://docs.virtosoftware.com/docs/virto-workflow-automation-web-part/virto-sharepoint-workflow-activities-kit-sharepoint-2010-workflow-platform/database-activities/sql-script-to-read-data/)
Product: Virto Workflow Automation Web Part
Updated: 2026-08-12


This activity executes SQL statements within SharePoint Designer workflows and returns the result back to the workflow.

![Execute SQL Script to Read Data activity configured to return a result into a workflow variable](https://img-docs.virtosoftware.com/wp-content/uploads/2024/10/execute_sql_script_to_read_data_1.png)

***Note**: The default provider is MS SQL Server (System.Data.SqlClient). You can use other providers like ODBC, Oracle, etc.*

This activity supports multiple batches separated by the `GO` command. `GO` is not a Transact-SQL statement; it is a command recognized by this activity. The activity interprets `GO` as a signal to send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements includes all statements entered since the last `GO`, or since the start of the session if it is the first `GO`. A Transact-SQL statement cannot occupy the same line as a `GO` command, though the line can contain comments.

To return a result from the SQL script to the workflow, you should assign the output to the output variable.

## **Working with Parameter Placeholders**

The syntax for parameter placeholders depends on the data provider. The .NET Framework data providers handle naming and specifying parameters and parameter placeholders differently, with syntax customized for each data provider. The syntax for common data providers is described in the table below:


| Data provider | Parameter naming syntax |
|---|---|
| [System.Data.SqlClient](https://msdn.microsoft.com/en-us/library/system.data.sqlclient(v%3Dvs.110).aspx) | Uses output parameters in the format `@output_result`. |
| [System.Data.OleDb](https://msdn.microsoft.com/en-us/library/system.data.oledb(v%3Dvs.110).aspx) | Uses positional parameter markers indicated by a question mark `?`. |
| [System.Data.Odbc](https://msdn.microsoft.com/en-us/library/system.data.odbc(v%3Dvs.110).aspx) | Uses positional parameter markers indicated by a question mark `?`. |
| [System.Data.OracleClient](https://msdn.microsoft.com/en-us/library/system.data.oracleclient(v%3Dvs.110).aspx) | Uses output parameters in the format `:output_result` (or `output_result`). |


## **Example: Sql script for System.Data.SqlClient provider**

```
GO
DECLARE @var1 VARCHAR(10);
SET @var1 = 'sample';
SET @output_result = @var1;
GO
```

## **Example: Sql script for System.Data.OleDb provider**

```
GO
DECLARE @var1 VARCHAR(10);
SET @var1 = 'test';
SET ? = @var1;
GO
```

## **SharePoint Workflow Designer Phrase**

Execute **SQL Script** **this SQL script** using **this provider name**, **this connection string**, and store result in **Variable**

**Parameters**


| Parameter | Description |
|---|---|
| this SQL script | SQL statements. Supports multiple batches separated by the `GO` command. |
| this provider name | The .NET ADO Provider. Default is MS SQL Server (`System.Data.SqlClient`). You can also use:; - `System.Data.Odbc` - ODBC Data Provider; - `System.Data.OleDb` - OleDb Data Provider; - `System.Data.OracleClient` - OracleClient Data Provider; - `System.Data.SqlServerCe.3.5` - Microsoft SQL Server Compact Data Provider; For more information about providers, see [here](http://msdn.microsoft.com/en-us/library/dd0w4a2z.aspx). |
| this connection string | The connection string, e.g., `Data Source=localhost\SQLExpress;Initial Catalog=test;Integrated Security=SSPI`. |
| Variable | Gets or sets the output result. |

