SQL Server Update

This Snap executes an SQL UPDATE statement against a SQL Server database.

The SQL Server Update Snap executes an SQL update with the given properties. Document keys will be used as the column update, and their values will be used as the updated column value.

This Snap supports SQL Server 2008 or later versions.

Note: Updates will be batched up until the account's batch size property or until the structure of the update statement changes. An update statement will change if an incoming document contains different keys than a previous document.


Supported Accounts

  • This is a Write-type Snap.

Prerequisites

None.

Limitations and known issues

None.

Snap views

Type Description Examples of upstream and downstream Snaps
Input This Snap has exactly one document input view. Document keys will be used as the column update, and their values will be used as the updated column value.
Output Optional. This Snap has at most one output view. If an output view is available, then the original document that was used to create the statement will be output along with the status of the update executed.
Learn more about Error handling.

Snap settings

Note: Learn about the common controls in the Snap settings dialog.
Field/Field set Description

Label

String
Required.Specify a unique name for the Snap. Modify this to be more appropriate, especially if there are more than one of the same Snap in the pipeline.

Default value: SQL Server - Update

Schema Name

String/Expression/ Suggestion

Optional. Specify the database schema name. The property is suggestible and will retrieve available database schemas during suggest values.

Note: The values can be passed using the pipeline parameters but not the upstream parameter.

Default value: N/A

Example: dbo

Table Name

String/Expression/ Suggestion

Required. Specify the name of the table in which to update data. The table name is suggestible and requires an account setting.

Note: The values can be passed using the pipeline parameters but not the upstream parameter.

Default value: N/A

Example: Customers

Update Condition

String/Expression

Optional. Specify the SQL WHERE clause of the update statement. You can define specific values or columns to update (Set condition) in the upstream Snap, such as Mapper Snap, and then use the WHERE clause to apply these conditions on the columns sourced from the upstream Snap.

Examples:

Without using expressions

Using expressions

  • "EMPNO=$EMPNO and ENAME=$EMPNAME"
  • email = $email
  • emp=$emp
  • "emp='" + $emp + "'"
  • "EMPNO=" + $EMPNO + " and ENAME='" + $EMPNAME+ "'"
Warning: Using expressions that join strings together to create SQL queries or conditions has a potential SQL injection risk and is hence unsafe. Ensure that you understand all implications and risks involved before using concatenation of strings with '=' Expression enabled.

In certain scenarios where you want to use specific data from the upstream Snaps, and do not want to change that data in the Update Snap, then you need to place the data in the original structure of the input document. Hence, we recommend that you use the format for Update condition and input data format as shown below:

{
"valueToUpdate" : "true",
"original": {
"col1" : "KEY"
}
}
Note: If the Update Condition field is left blank, the condition is applied on all the records of the target table.

Default value: N/A

Number of retries

Integer/Expression

Specify the maximum number of attempts to be made to receive a response. The request is terminated if the attempts do not result in a response.

Default value: 0

Example: 3

Retry interval (seconds)

Integer/Expression

Specify the time interval between two successive retry requests. A retry happens only when the previous attempt resulted in an exception.

Default value: 1

Example: 10

Snap execution

Dropdown list
Choose one of the three modes in which the Snap executes. Available options are:
  • Validate & Execute: Performs limited execution of the Snap and generates a data preview during pipeline validation. Subsequently, performs full execution of the Snap (unlimited records) during pipeline runtime.
  • Execute only: Performs full execution of the Snap during pipeline execution without generating preview data.
  • Disabled: Disables the Snap and all Snaps that are downstream from it.

Default value: Execute only

Note: TIMESTAMP datatype in SQL Server is not supported. According to the Microsoft official document, "The timestamp syntax is deprecated. This feature will be removed in a future version of Microsoft SQL Server. Avoid using this feature in new development work, and plan to modify applications that currently use this feature."
Warning: In a scenario where the Auto commit on the account is set to true, and the downstream Snap depends on the data processed on an Upstream Database Bulk Load Snap. Use the Script Snap to add delay for the data to be available.

For example, when performing a create, insert and a delete function sequentially on a pipeline, using a Script Snap helps in creating a delay between the insert and delete function or otherwise it may turn out that the delete function is triggered even before inserting the records on the table.