SQL Server - Table List

In this article

Overview

You can use this Snap to output a list of tables in a database. The Snap will connect to the database, read its metadata, and output a document for each table found in the database. The table names are output in a topological order so that tables with the fewest dependencies are output first. In other words, if table A has a foreign key reference to table B, then table B will be output before A. The ordering is intended to ease the process of replicating a group of tables from one database to another.

This Snap supports SQL Server 2008 or newer.

  • name -  The fully-qualified name of the table. To use the table name in another Snap, like a Select or Insert, you can pass it through a ForEach Snap to another pipeline with the Select or Insert.

  • type - The type of table. This value is currently fixed to the string "TABLE".

  • dependents - (If Compute table graph is selected) A list of table names that have references to this table, including this table.

Replicating a Subset of Tables

The output of the Table List Snap can be directly used to replicate an entire database.  However, if you are only interested in a subset of tables, you can use a Filter Snap to select the table names you are interested in as well as the tables that they reference. For example, given the following diamond-shaped table graph where A depends on B and C and they both depend on D:
 

A / \ B C \ / D

The Table List will output the following documents:

name=D; dependents=[A, B, C, D] name=C; dependents=[A, C] name=B; dependents=[A, B] name=A; dependents=[A]

So, if you wanted to copy just table 'A' and its dependencies, you can add a Filter Snap with the following expression:

$.dependents.indexOf('A') != -1

The filter will then remove any extra tables that happen to be in the schema. 

Snap Type

SQL Server - Table List Snap is a Read-type Snap that lists the tables in a database

Prerequisites

None.

Support for Ultra Pipelines

Works in Ultra pipelines.

Limitations & Known Issues

None.

Snap Views

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Type

Format

Number of Views

Examples of Upstream and Downstream Snaps

Description

Input

Document

  • Min: 0

  • Max: 1

  • Mapper Snap

This Snap has at most one input views.

Output

Document

  • Min: 1

  • Max: 1

  • Join Snap

This Snap has at most one output view.

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 (): Indicates a list that is dynamically populated based on the configuration.

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

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

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

Field Name

Field Type

Description

Label*

 

Default ValueSQL Server - Table List
Example: SQL Server - Table List

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. Selecting a schema filters the Table name list to show only those tables within the selected schema. The property is suggestible and will retrieve available database schemas during suggest values.

Compute table graph

 

Default Value: Deselected

Checkbox

Specify the dependents among tables and returns each table with a list of tables it has foreign key references to. The ordering of outputted tables is from least dependent to most-dependent. Note that as turning on this option will significantly slow down the Snap, it should be left as off unless you need it. 

Number of retries

 

Default Value: 0
Example3

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.

 

Retry interval (seconds)

 

Default Value: 1
Example10

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

Dropdown list

Examples

In the following example, the Table List Snap retrieves all the tables under schema 'dbo' and writes it to output view. 

 

The sample output view data is shown below:

Snap Pack History