Snap type: | Read | |||||||
---|---|---|---|---|---|---|---|---|
Description: | This Snap allows you 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. SELECT [output fields] FROM [table] WHERE [where clause] ORDER BY [ordering] LIMIT [limit] OFFSET [offset]
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). | |||||||
Prerequisites: | None | |||||||
Support and limitations: |
| |||||||
Account: | This Snap uses account references created on the Accounts page of SnapLogic Manager to handle access to this endpoint. See SQL Server Account for information on setting up this type of account. | |||||||
Views: |
| |||||||
Settings | ||||||||
Label | Required. 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 | 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. Example: SYS | |||||||
Table Name | Required. The table to execute the select query on. Default value: [None] | |||||||
Where clause | The where clause of a 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). Example: email = 'you@example.com' or email = $email | |||||||
Order by | Enter in the columns in the order in which you want to order by. The default database sort order will be used. Example: name Default value: [None] | |||||||
Limit offset | Starting row for the query. Example: 0 Default value: [None] | |||||||
Limit rows | Number of rows to return from the query. Example: 10 Default value: [None] | |||||||
Output fields | Enter or select output fields for SQL SELECT statement. To select all fields, leave it at default. Example: email, address, first, last, etc. Default value: [None] | |||||||
Pass through | If selected, the input document will be passed through to the output view under the key 'original'. Default value: Selected | |||||||
Ignore empty result | Enter or select output fields for SQL SELECT statement. To select all fields, leave it at default. Example: email, address, first, last, etc. Default value: Not selected |
You can reference pipeline parameters in SQL statements/fragments by doing '$.eval(_myparam)'.
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."
For the 'Suggest' in the Order by columns and the Output fields properties, the value of the Table name property should be an actual table name instead of an expression. If it is an expression, it will display an error message "Could not evaluate accessor: ..." when the 'Suggest' button is pressed. This is because, at the time of "Suggest" button pressed, the input document is not available for the Snap to evaluate the expression in the Table name property. The input document is available to the Snap only during the preview or execution time.
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: