$customHeader
Skip to end of banner
Go to start of banner

SQL Server - Select

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 63 Next »

In this article

Overview

You can use this Snap to fetch data from a SQL Server database by providing a table name and configuring the connection. The Snap produces the records from the database on its output view which can then be processed by a downstream Snap. 

JSON paths can be used in a query and will have values from an incoming document substituted into the query. However, documents missing values for a given JSON path will be written to the Snap's error view. After a query is executed, the query's results are merged into the incoming document overwriting any existing keys' values. The original document is output if there are no results from the query.

Queries produced by the Snap have the format:

SELECT [output fields] FROM [table] WHERE [where clause] ORDER BY [ordering] LIMIT [limit] OFFSET [offset]
  • This Snap supports SQL Server 2008 or newer. 

  • The sub-millisecond time accuracy for all date/time data types is not supported.

  • The where clause can only use variables, not constants or Pipeline parameters. A good example of a where clause is: SALARY =$SALARY (here we use the SALARY variable of the input document).

Getting Encrypted Data from the Database

  • To get the values of the query result as plain text in the output, enter the following URL properties (Url property name and Url property value) in the SQL Server account that the Snap uses.

      columnEncryptionSetting: Enabled

  • If you have encryption columns that are created using java keystore, enter the following additional URL properties along with columnEncryptionSetting.

      keyStoreLocation: /path/to/jksfile

   keyStoreSecret: <password_used_to_create_jks>

   keyStoreAuthentication: JavaKeyStorePassword (fixed value)

Snap Type

SQL Server - Select Snap is a Read-type Snap that executes SQL SELECT statement.

Prerequisites

None.

Support for Ultra Pipelines

  • Works in Ultra pipelines.

  • Pipelines fail in the execution mode whenever a value is set in the Limit Offset property.

Limitations & Known Issues

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input

Document

  • Min: 0

  • Max: 1

  • Mapper Snap

This Snap allows none or one input view. If the input view is defined, then the where clause can substitute incoming values for a given expression (in such as to use it as a lookup).

Output

Document

  • Min: 1

  • Max: 2

  • Join Snap

This Snap has one output view by default and produces one document for each row in the table. A second view can be added to show the metadata for the table as a Document. The metadata document can then be fed into the second input view of SQL Server - Insert or Bulk Load Snap so that the table is created in SQL Server with a similar schema as the source table.

Error

Error handling is a generic way to handle errors without losing data or failing the Snap execution. You can handle the errors that the Snap might encounter when running the Pipeline by choosing one of the following options from the When errors occur list under the Views tab:

  • Stop Pipeline Execution: Stops the current pipeline execution if the Snap encounters an error.

  • Discard Error Data and Continue: Ignores the error, discards that record, and continues with the remaining records.

  • Route Error Data to Error View: Routes the error data to an error view without stopping the Snap execution.

Learn more about Error handling in Pipelines.

Snap Settings

  • Asterisk (*): Indicates a mandatory field.

  • Suggestion icon ((blue star)): Indicates a list that is dynamically populated based on the configuration.

  • Expression icon ((blue star)): Indicates whether the value is an expression (if enabled) or a static value (if disabled). Learn more about Using Expressions in SnapLogic.

  • Add icon ((blue star)): Indicates that you can add fields in the field set.

  • Remove icon ((blue star)): Indicates that you can remove fields from the field set.

Field Name

Field Type

Description

Label*

Default ValueSQL Server - Select
Example: SQL Server - Select

String

Specify the name for the Snap. You can modify this to be more specific, especially if you have more than one of the same Snap in your Pipeline.

Schema Name

Default Value: N/A
Example: schema_demo

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

Table Name*

Default Value: N/A
Example: employees_table

String/Expression

Specify the table to execute the select query on.

Where Clause 

Default Value: N/A
Example: SELECT * FROM employees WHERE salary > 50000

String/Expression

Specify the WHERE clause of the SELECT statement. This supports document value substitution (such as $person.firstname will be substituted with the value found in the incoming document at the path). However, you may not use a value substitution after "IS" or "is" word.

Examples:

Without using expressions

  • EmpId = 12 

  • email = 'you@example.com'

Using expressions

  • "EMPNO=$EMPNO and ENAME=$EMPNAME"

  • email = $email 

  • emp=$emp

  • "emp='" + $emp + "'"

  • "EMPNO=" + $EMPNO + " and ENAME='" + $EMPNAME+ "'"

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. 

Order By 

Use this fieldset to specify the columns in the order in which you want to sort the database. The default database sort order will be used.

Column Names

 

Default Value: N/A
Example: name

String/Expression

Specify the column names.

Limit Offset

Default Value: N/A
Example: 0

Integer/Expression

Specify the offset for the limit clause. This is where the result set should start. Starting row for the query. Note that some databases do not support OFFSET, such as Teradata, and the Limit offset property is ignored.

Limit Rows 

Default Value: N/A
Example: 10

Integer/Expression

Specify the number of rows to return from the query.

Query Hints

Default Value: N/A
Example: OPTION (USE HINT ('DISABLE_OPTIMIZER_ROWGOAL'))

String/Expression

Specify the hints to customize and optimize the database engine in processing the query statement.

Query hints that are supported are dependent on the SQL database version. For instance, SELECT * from sys.dm_exec_valid_use_hints query helps you list out the hints that are supported by a specific database.

Output fields

Use this fieldset to specify the output fields for SQL SELECT statement.

Output Field

Default Value: N/A
Example: email, address, first, last

String/Expression

Specify or select output field names for SQL SELECT statement. To select all fields, leave it at default.

Fetch Output Fields In Schema

Default Value: Deselected

Checkbox

Select this check box to include only the selected fields or columns in the Output Schema (second output view). If you do not provide any Output fields, all the columns are visible in the output.
If you provide output fields, we recommend you to select Fetch Output Fields In Schema check box.

Pass-through 

Default Value: Selected

Checkbox

Select to pass the input document will be pass through the output view under the key 'original'. 

Ignore empty result

Default Value: Deselected

Checkbox

Select this checkbox if you do not want to write to the output view when a SELECT operation does not produce any result or is empty. If you do not select this property and selected the Pass through property, the input document is passed through to the output view.

Auto Commit

Default Value: False
Example: True

Dropdown list

Select one of the options for this property to override the state of the Auto commit property on the account. The Auto commit at the Snap-level has three values: TrueFalse, and Use account setting. The expected functionality for these modes are:

  •  True - The Snap will execute with auto-commit enabled regardless of the value set for Auto commit in the Account used by the Snap.

  •  False - The Snap will execute with auto-commit disabled regardless of the value set for Auto commit in the Account used by the Snap.

  • Use account setting - The Snap will execute with Auto commit property value inherited by the Account used by the Snap.

Match data types

Default Value: Deselected

Checkbox

This property applies only when the Output fields property is provided with any field value(s).

If this property is selected, the Snap tries to match the output data types same as when the Output fields property is empty (SELECT * FROM ...). The output preview would be in the same format as the one when SELECT * FROM is implied and all the contents of the table are displayed.

Number of Retries

Default Value: 0
Example: 3

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.

  • If the value is larger than 0, the Snap first downloads the target file into a temporary local file. If any error occurs during the download, the Snap waits for the time specified in the Retry interval and attempts to download the file again from the beginning. When the download is successful, the Snap streams the data from the temporary file to the downstream Pipeline. All temporary local files are deleted when they are no longer needed.

  • Ensure that the local drive has sufficient free disk space to store the temporary local file.

Retry Interval (seconds)

Default Value: 1
Example:  10

Integer/Expression

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

Staging mode

Default Value: In memory
Example: On disk

Dropdown list

Required when the value in the Number of retries field is greater than 0. 

Specify the location from the following options to store input documents between retries:

  • In memory: The query results are stored in the Snaplex memory. If the query is too large to fit in the memory space, it may cause the Snap to fail, choose the On disk option.

  • On disk: The query results are stored on the disk in a temporary (tmp) directory that is managed by the SnapLogic platform. This directory is deleted automatically when the Snap terminates.

Option for Unique Identifier Column

Default Value: Convert to lower case
Example: Convert to upper case

Dropdown list

This propery applies only when the Snap returns the unique identifier (GUID) in the output.

Specify the unique identifier is stored in the database using an internal format and when it is displayed in the output, it is converted to a string and gets displayed in upper case for HEX characters. Select either of the following options to change the case type. Available options are:

  • Convert to lower case: Modifies the output string to lower case.

  • Convert to upper case: Modifies the output string to upper case.

Page lookup error: page "Anaplan Read" not found.

If you're experiencing issues please see our Troubleshooting Guide.

Default Value: Validate & Execute
Example: Execute only

Dropdown list

Page lookup error: page "Anaplan Read" not found.

If you're experiencing issues please see our Troubleshooting Guide.

Examples

In this example, we will show how to retrieve data from a table called 'customer'.

We can pass the dynamic variable used in where clause from upstream Snap like JSON Generator. We try to retrieve customers by their name. 

The sample output looks like below:


Snap Pack History

 Click here to expand...

Release 

Snap Pack Version

Date

Type

Updates

May 2024

main26341

Stable

Updated the Delete Condition (Truncates a Table if empty) field in the SQL Server - Delete Snap to Delete condition (deletes all records from a table if left blank) to indicate that all entries will be deleted from the table when this field is blank, but no truncate operation is performed.

February 2024

436patches26177

Latest

  • Fixed an issue with the SQL Server Snap Pack that displayed an error when numeric values with scale 0 were inserted into the database with DECIMAL or NUMERIC type columns, instead of inserting the value with decimal digits truncated.

  • Fixed an issue with the SQL Server Snap Pack that displayed an error when fractional numeric values (numbers with a decimal point) were inserted into the database with an INT type column, instead of inserting the value with decimal digits truncated.

February 2024

436patches25757

Latest

Fixed an issue with the SQL Server - Insert Snap that previously displayed an error when attempting to insert a true or false value into a TinyInt datatype. The Snap now correctly inserts 1 or 0 for true or false in the table, respectively. 

February 2024

436patches25548

Latest

  • Added support for XML and spatial types (Geography and Geometry) for SQL Server Snap Pack.

  • Fixed an issue with the SQL Server - Insert Snap that displayed an error when an empty or blank string was passed as a value to an integer-type column.

Behavior change:
As part of the JOOQ upgrade done in main25112, the SQL Server-Insert Snap displayed the following error when an empty string was inserted to an integer-type column:
Caused by: java.lang.NumberFormatException: Character n is neither a decimal digit number, decimal point, nor "e" notation exponential mark
Now, the Snap inserts a null value in this scenario.

February 2024

main25112

Stable

As of main25112, the SQL Server Snap Pack no longer supports the jDTS driver. If you are using the latest SQL Server driver versions (2014 and higher), we recommend you use the driver that is bundled with the SQL Server Snap Pack. Note that the older SQL Server versions are supported as is.

November 2023

main23721

Stable

Updated and certified against the current SnapLogic Platform release.

August 2023

434patches22758

Latest

Fixed an issue with the SQL Server Stored Procedure and Table List Snaps that caused no retries to be executed even if you select the number of retries in the UI when a custom JDBC driver was used.

August 2023

434patches22579

Latest

Improved the SQL Server Bulk Load Snap to reduce the chance of causing a deadlock error.

August 2023

main22460

Stable

The SQL Server - Execute Snap now includes a new Query type field. When Auto is selected, the Snap tries to determine the query type automatically.

May 2023

433patches22090

Latest

The SQL Server Stored Procedure and SQL Server Table List Snaps now support the retry functionality.

May 2023

433patches21808

Latest

  • The SQL Server Snap Pack is upgraded to the latest version of the Microsoft JDBC Driver 12.2.0.jre11 for SQL Server:

    • Pipelines using the default JAR in the SQL server accounts might fail after the driver upgrade because the latest driver is backward-incompatible. To prevent your accounts from failing, reconfigure the URL properties field in account settings as follows:

      trustServerCertificate = true

    • Pipelines NOT using the default driver (bundled with the SQL Server Snap Pack) will not fail.
      Note: This update will be a part of the stable distribution with the GA release on August 9, 2023.
      Learn more about the SQL Server driver upgrade: FAQ for Upgrading to SQL Server JDBC Driver 12.2.0

  • Fixed an issue with the SQL Server Insert Snap that was causing performance degradation between GA release 4.32 and 4.33 if the network connection between the Groundplex and the database server was slow.

May 2023

433patches21386

 

-

The SQL Server Snap Pack is upgraded to the latest version of the Microsoft JDBC Driver 12.2.0.jre11 for SQL Server:

  • Pipelines using the default JAR in the SQL server accounts might fail after the driver upgrade because the latest driver is backward-incompatible. To prevent your accounts from failing, reconfigure the URL properties field in account settings as follows:

    trustServerCertificate = true

  • Pipelines NOT using the default driver (bundled with the SQL Server Snap Pack) will not fail.

The Microsoft JDBC Driver 12.2.0.jre11 for SQL Server included in the SQL Server Snap Pack is currently NOT available with the latest distribution. However, you can still consume this patch through 433patches21386. This update is scheduled to be included in the upcoming distribution release on July 12, 2023, and will be a part of the stable distribution with the GA release on August 9, 2023.

May 2023

433patches21119

 

Latest

Updated the Bulk Load Snap to preserve empty strings as empty strings and null as nulls.

May 2023

main21015

 

Stable

Upgraded with the latest SnapLogic Platform release.

February 2023

main19844

 

Stable

Upgraded with the latest SnapLogic Platform release.

November 2022

431patches19263

 

Latest

The SQL Server Insert Snap no longer no longer includes the Preserve case-sensitivity checkbox because the database is case-insensitive. The database stores the data regardless of whether the columns in the target table and the input data are in mixed, lower, or upper case.

November 2022

431patches19268

 

Latest

The SQL Server-Insert Snap now displays the error, Number overflow: <number> (instead of Batch operation failed) when inserting a number into tinyinit column.

November 2022

431patches19234

 

Latest

A memory leak in the SQL Server Stored Procedure Snap is fixed. The Snap now clears the closed connections from memory and retains the open connections.

November 2022

431patches19000

 

Stable/Latest

The SQL Server accounts failed with a certificate error on Windows Snaplexes when using the default SQL driver with the 4.31 main18944 build. This patch addresses the certificate error issue.

November 2022

main18944

 

Stable

The MySQL Insert Snap now creates the target table only from the table metadata of the second input view when the following conditions are met:

  • The Create table if not present checkbox is selected.

  • The target table does not exist.

  • The table metadata is provided in the second input view.

August 2022

430patches17064

 

Latest

The SQL Server - Select Snap now has the Convert rowversion datatype to integer checkbox to support the ROWVERSION data type. Select this checkbox to display the ROWVERSION data type as integers in the output.

4.30 Patch

430patches17368

 

Latest

The SQL Server Execute Snap containing an explicit SQL transaction now works as expected when using a default JDBC driver.

August 2022

main17386

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.29 Patch

429patches16235

 

Latest

Fixed an issue with SQL Server Execute Snap where the Snap did not display a valid error message when the delete condition is invalid.

4.29

main15993

 

Stable

Enhanced the SQL Server - Bulk Load Snap with the Batch Size field to process records in a batch.

4.28 Patch

428patches14649

 

Latest

Enhanced the SQL Server - Select and SQL Server - Lookup Snaps with Option for Unique Identifier Column that allows you to convert the case to lower or upper while displaying the Unique Identifier output (display) value.

4.28

main14627

 

Stable

Updated the label for Delete Condition to Delete Condition (Truncates Table if empty) in the SQL Server Delete Snap.

4.27

main12833

 

Stable

Enhanced the SQL Server - Execute Snap to invoke stored procedures.

4.26 Patch

426patches12535

Latest

Fixed an issue in the SQL Server Bulk Load snap where boolean data type failed to load into BIT field.

4.26

main11181

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.25 Patch

425patches10797

 

Latest

Fixed an issue with the SQL Server - Bulk Load Snap where the Snap fails when the login password contains a colon or a less than (<) symbol.

4.25

main9554

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.24 Patch

424patches8657

 

Latest

Enhances the SQL Server - Select Snap by introducing a new field, Query Hints, which helps to customize and optimize the database engine to process query statements.

4.24

main8556

Stable

  • Enhances the SQL Server - Select Snap to return only the selected output fields or columns in the output schema (second output view) using the Fetch Output Fields In Schema check box. If the Output Fields field is empty all the columns are visible.

  • Enhances the SQL Server - Stored Procedure to accept parameters from input documents by column keys. If the values are empty, the parameters are populated based on the column keys for easier mapping in the upstream Mapper Snap.

4.23 Patch

423patches8190

 

Latest

Fixes an issue with SQL Server - Execute to handle SQL statements that begin with special characters.

4.23

main7430

 

Stable

Enhances the accounts in this Snap Pack to allow Windows-based (Active Directory) authentication and user impersonation for SQL Server user accounts.

4.22 Patch

422patches6728

 

Latest

Enhances the SQL Server Snap pack to allow Windows (Active Directory) based authentication and user impersonation for SQL Server user accounts.

4.22

main6403

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.21 Patch

421patches6272

 

Latest

Fixes the issue where Snowflake SCD2 Snap generates two output documents despite no changes to Cause-historization fields with DATE, TIME and TIMESTAMP Snowflake data types, and with Ignore unchanged rows field selected.

4.21 Patch

421patches6144

 

Latest

Fixes the following issues with DB Snaps:

  • The connection thread waits indefinitely causing the subsequent connection requests to become unresponsive.

  • Connection leaks occur during Pipeline execution.

4.21 Patch

MULTIPLE8841

 

Latest

Fixes the connection issue in Database Snaps by detecting and closing open connections after the Snap execution ends. 

4.21 Patch 

db/sqlserver8837

 

Latest

Fixed the SQL Server - Stored Procedure Snap to support the UUID datatype.

4.21

snapsmrc542

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.20 Patch 

db/sqlserver8793

 

Latest

Fixed an issue in the SQL Server - Insert Snap due to which the Snap failed to load values of data type INT.

4.20 Patch 

db/sqlserver8796

 

Latest

Fixed the SQL Server - Bulk Load Snap to mask the password in the logged exception messages. 

4.20

snapsmrc535

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.19 Patch 

db/sqlserver8413

 

Latest

Fixed an issue with the SQL Server - Update Snap wherein the Snap is unable to perform operations when:

  • An expression is used in the Update condition property.

  • Input data contain the character '?'.

4.19

snaprsmrc528

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.18 Patch

 db/sqlserver7989

 

Latest

Fixed an issue in the SQL Server - Merge Snap wherein identity columns are not handled correctly. Also, added a field, Enable Identity Insert, that enables you to insert values into an identity column.

4.18

snapsmrc523

 

Stable

  • Added support for SQL Server account Active Directory authentication for SQL server for driver JAR version mssql-jdbc-6.2.2-jre8.jar.

  • Reverts a 4.17-patch (db/sqlserver7394) update regarding how BIT and BOOLEAN column data type values are displayed. They now display as true or false (4.17 GA behavior in snapsmrc515) rather than converting to 0 or 1 values (4.17-patch behavior).

4.17 Patch

MULTIPLE7479

 

Latest

Fixed an issue with the SQL Server - Lookup Snap wherein it fails a UUID search.

4.17

ALL7402

 

Latest

Pushed automatic rebuild of the latest version of each Snap Pack to SnapLogic UAT and Elastic servers.

4.17

snapsmrc515

 

Latest

  • Fixed an issue with the SQL Server Execute Snap wherein the Snap would send the input document to the output view even if the Pass through field is not selected in the Snap configuration. With this fix, the Snap sends the input document to the output view, under the key original, only if you select the Pass through field.

  • Added the Snap Execution field to all Standard-mode Snaps. In some Snaps, this field replaces the existing Execute during preview check box.

4.16 Patch

 db/sqlserver6981

 

Latest

Fixed an issue of slow performance in SQL Server Snaps while using SQL Server Dynamic account type. 

4.16 Patch 

db/sqlserver6818

 

Latest

Fixed an issue with the Lookup Snap passing data simultaneously to output and error views when some values contained spaces at the end.

4.16

snapsmrc508

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.15 Patch

 db/sqlserver6337

 

Latest

Replaced Max idle time and Idle connection test period properties with Max life time and Idle Timeout properties respectively, in the Account configuration. The new properties fix the connection release issues that were occurring due to default/restricted DB Account settings.

4.15

snapsmrc500

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.14 Patch 

db/sqlserver5912

 

Latest

Fixed an issue to parse the right data type and display it in the input schema for SQL Server Snap..

4.14 Patch 

db/sqlserver5665

 

Latest

Implemented a connection retry logic in the SQL Server account to resolve the connection loss issue in a customer's org.

4.14

snapsmrc490

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.13

snapsmrc486

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.12

snapsmrc480

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.11 Patch 

db/sqlserver4388

 

Latest

Fixed an issue with the Stored Procedure Snap that does not maintain the columns' order on the output as per table's definition.

4.11 Patch

 db/sqlserver4288

 

Latest

 SQL Server Snap Pack - Fixed an issue when inserting a valid NaN value into a column.

4.11

snapsmrc465

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.10 Patch

sqlserver3953

 

Latest

Fixed an issue where the SQL Server Stored Procedure gets hanged when more than one Snap existed in the pipeline each processing greater than 1K documents.

4.10

snapsmrc414

 

Stable

Added Auto commit property to the Select and Execute Snaps at the Snap level to support overriding of the Auto commit property at the Account level.

4.9.0 Patch

sqlserver3224

 

Latest

Addressed an issue with SQL Server - Bulk Load execution even with 0 input documents

4.9.0 Patch

sqlserver3076

 

Latest

Fixed an issue regarding connection not closed after login failure; Expose autocommit for "Select into" statement in PostgreSQL Execute Snap and Redshift Execute Snap

4.9

snapsmrc405

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.8.0 Patch

sqlserver2803

 

Latest

Addressed an issue with slow performance with Bulk Load BCP.

4.8.0 Patch

sqlserver2761

 

Latest

Potential fix for JDBC deadlock issue.

4.8.0 Patch

sqlserver2706

 

Latest

Fixed SQL Server Snap Pack rendering dates that are one hour off from the date returned by database query for non-UTC Snaplexes.

4.8

snapsmrc398

 

Stable

Upgraded with the latest SnapLogic Platform release.

4.7

snapsmrc382

 

Stable

  • Extended support for SQL Server Dynamic accounts.

  • Updated the SQL Server Stored Procedure Snap with the Pass through field. 

4.6

snapsmrc362

 

Stable

  • Resolved an issue in SQL Server Bulk Load Snap that caused BCP program related failures.

  • Enhanced to fully support SQL statements with/without expressions & SQL bind variables.

  • Resolved an issue that caused failures when executing merge statements.

4.5.1

snapsmrc344

 

Latest

Upgraded with the latest SnapLogic Platform release.

4.5

snapsmrc344

 

Stable

  • Resolved an issue in SQL Server Execute Snap that erroneously reported a database/schema mismatch during Snap/pipeline execution.

  • Resolved an issue in SQL Server Lookup Snap that occurred when handling case-insensitive field values.

4.4.1

NA

 

Latest

  • Introduced the SQL Bulk Load in this release.


Related Content

  • No labels