SQL Server Merge

You can use this Snap to execute a SQL Merge with the specified properties.

Note:
  • The merge condition can only use variables; it does not support constants and pipeline parameters. For example SALARY =$SALARY (here, we use the SALARY variable of the input document). However, if you use SALARY = '100000' (the Snap cannot process this condition, because the provided columns in the condition are validated against the types defined in the table schema). You can rewrite this condition by using an upstream Mapper Snap, where '10000' is mapped to the SALARY variable, which then can be used in the Merge condition as defined in the earlier example. The same applies to pipeline parameters, which should be mapped upstream similarly using a Mapper Snap.
  • Merges are batched until the account's batch size property or until the structure of the update statement changes. An update statement changes if an incoming document contains different keys than a previous document.
  • While the expression enabler is available on the Merge condition field, we recommend you to minimize the usage of the expression enabler for the Merge condition field.


Supported Accounts

  • This is a Write-type Snap.

Snap Type

SQL Server - Merge Snap is a Write-type Snap that executes an SQL Server merge.

Supported Versions

This Snap supports SQL Server 2008 or higher versions.

Support for Ultra Pipelines

Works in Ultra Pipelines.

Snap views

Type Description Examples of upstream and downstream Snaps
Input

The documents that are provided in the input view will be merged into the provided table on the provided database.

  • Min: 1
  • Max: 1

Each document on the input view is expected to be merged or created with/as a new record in the table. The input view schema is provided to an upstream Mapper Snap, based on the selected service object.

Output

If an output view is available, then the original document that was used to create the statement will be output with the status of the merge executed.

  • Min: 0
  • Max: 1

A document which represents the status of the merge operation for that document. Each merge operation is represented as one document in the output view.

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 - Merge

Schema name

String/Expression

Specify the database schema name. In case it is not defined, then the suggestion for the Table Name will retrieve all tables names of all schemas. 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: schema_demo

Table name

String/Expression

Required. Specify the table to execute the merge on.

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

Default value: N/A

Example: employees_table

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.

Note:
  • When you enable retry and a connection failure occurs that cannot be recovered by retry, the Snap writes a connection failure error in the error view. In some cases, the error view records might contain duplicate data that was written to the database. Ensure to verify all the records in the error file before you restart the merge request. You can locate the duplicate records in the error view by checking the $reason property for the sub-string: Connection is not available, request timed out.
  • Ensure that the local drive has sufficient free disk space to store the temporary local file.

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.

Note: When you enable retry and a connection failure occurs that cannot be recovered by retry, the Snap writes a connection failure error in the error view. In some cases, the error view records might contain duplicate data that was written to the database. Ensure to verify all the records in the error file before you restart the merge request. You can locate the duplicate records in the error view by checking the $reason property for the sub-string: Connection is not available, request timed out.

Default value: 1

Example: 10

Merge condition

String/Expression

Required. Specify the ON condition of the merge statement. A boolean-type expression is expected. See Merge Syntax for an explanation of merge syntax.

Default value: N/A

Example: SALARY =$SALARY

Identity column

String/Expression

Specify the table's identity column. If this is not set and the column is set to be generated always, then the merge will fail.

Default value: N/A

Example: EmployeeID

Enable identity insert

Checkbox

Select the check box to insert values from the input document into the target table identity column. Ensure that the target table contains an identity column. If you do not select the check box, then the Snap strips any value that is meant for the identity column from the input document.

Default status: Deselected

Snap execution

Dropdown list

Select 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: Validate & Execute

Example: Execute only