SQL Statement

The SQL Statement Task Type is used for executing SQL directly on a connection. Currently the SQL Statement task can only be used with SQL Server connections, supporting T-SQL syntax validation.

Providing the Statement


SQL Statements can be provided directly in-task using the statement editor provided, or the path to a .sql file can be used in place of the statement. Either way, this statement can be “verified” for any syntactic issues using the “Verify SQL Statement” button located underneath the task.

SQL Statement Verification may sometimes fail if working with entities that do not exist yet. Verification is not required so it is possible that completely valid SQL may result in a failed verification due to conditions outside of the statement.

Utilizing Parameters

SQL Statements support parameters which can be used to provide variables that can be modified at a job sequence level. This means you could have the same SQL Statement task with different results and effects depending on what parameter is provided.

Parameters can be referenced in script using the T-SQL local variable syntax of @PARAMETER_NAME.

Parameter values need to be set when the task is added to a job’s sequence. Learn more about parameters in the jobs documentation.

Example Variable Usage

Param Name Param Value Script Formatted Script
Name Alex SELECT * FROM People WHERE [FirstName] = @NAME SELECT * FROM People WHERE [FirstName] = 'Alex'

To learn how to use a File Connection as your Script Source to execute a script in a file in your Git Repository, please read more here.