# Microsoft SQL Server

<figure><img src="https://content.gitbook.com/content/U61B9DqtWCNO3Z30vnjh/blobs/i862A2RYfjHWzxZfKb6f/MicrosoftSQLServer.png" alt=""><figcaption><p>Source and Destination Databases</p></figcaption></figure>

## Before you begin

Before you begin, gather this connection information:

* Name of the server that hosts the database you want to connect to and port number
* User name and password
* Are you connecting to an SSL server?
* Do you want to set the database isolation level to read uncommitted data?

## Connect and set up the workspace

Launch Syntho and select **Connect to a database**, or **Create workspace**. Then select **Microsoft SQL Server** from **Type** under **The connection details**. For a complete list of data connections, click **Type** under **The connection details**. Then do the following:

1. Enter the name of the server that hosts the database that you want to connect to.
2. Enter the database name to connect to the contained database.
3. Enter the port number.
4. Enter user name and password.

   Select the **Require SSL** check box when connecting to an SSL server.
5. Select **Next**.\
   If Syntho can't make the connection, verify that your credentials are correct. If you still can't connect, your computer is having trouble locating the server. Contact your network administrator or database administrator.

## Considerations & limitations

* **Handling sensitive data in encoded images**: The `VARBINARY` data type may be used to store encoded images, which can potentially include sensitive information. Due to the complexity of replicating synthetic twins of such images, our product, Syntho, replaces values stored in `VARBINARY` columns with a dummy character to ensure data privacy and integrity. This approach prevents the accidental leakage of sensitive data.
* **Identity columns in table names with dots**: Table names with dots in their names are not supported when such tables contain `identity` columns. This limitation is due to the way the driver interprets table names with dots. These tables will have to be completely excluded from processing.
* **SQL variant data type**: Database columns with the data type `sql_variant` cannot use the key generation method "Duplicate". This is due to the way the used driver converts values. More details on the `sql_variant` data type can be found in the [Microsoft Documentation](https://learn.microsoft.com/en-us/sql/t-sql/data-types/sql-variant-transact-sql?view=sql-server-ver16).
* **JSON and XML types**: For JSON and XML columns, it is recommended to disable any format validation in the destination database.
* **Timestamp Column Restrictions**:
  * **Foreign key constraints**: Columns of the `TIMESTAMP` data type cannot be used as the target of foreign key (FK) constraints. This restriction stems from the nature of `TIMESTAMP` as a data type primarily used for version-stamping rows rather than linking rows across tables.
  * **Primary key constraints**: A `TIMESTAMP` column cannot be used as the sole primary key (PK) in a table. If a `TIMESTAMP` column is included in a primary key, it must be combined with one or more other columns.
  * For `TIMESTAMP` columns, the user should be aware that timestamps reflect the moment of writing to the destination database with values of the current system time.
* When entering database or schema names, use lowercase letters. Names containing capital letters must be entered in lowercase to ensure a proper connection.

## **Fast execute many**

`fast_executemany` is an option in Microsoft ODBC drivers that allows for faster data writing to SQL Server databases by optimizing the execution of multiple insert statements. While it can significantly improve performance, it comes with some limitations, particularly around robust datatype handling.

This feature can be enabled via the workspace default settings. Enable `fast_executemany` for SQL Server databases by setting its value to **true**.

```
"default_fast_executemany": true
```

## **Dropping and recreating indexes**

{% hint style="info" %}
**Coming soon**
{% endhint %}

Tables with many indexes may experience blocking or halting during data writing without any error messages. In such cases, considering dropping indexes for that table can resolve the issue.\
Syntho has a feature called **default\_drop\_indexes** that introduces logic for dropping indexes before writing data to SQL Server tables and recreating them afterward. This process is managed on a per-table basis and is controlled by a new engine attribute.\
\
**default\_drop\_indexes**: A boolean attribute that determines whether indexes should be dropped before writing and recreated afterward. Default value is false and currently, only the MSSQL connector supports this feature.

#### **Enabling index dropping**

To enable this feature, hold **CTRL + SHIFT + ALT + 0** to open the **Workspace Default Settings** menu. There, set the value to **true** for the **default\_drop\_indexes**.

```
default_drop_indexes = true
```

#### **Permissions required**

To execute the DROP INDEX command, the following permissions are required:

* **ALTER permission**: At a minimum, ALTER permission on the table or view is required.
  * This permission is granted by default to the sysadmin fixed server role and the db\_ddladmin and db\_owner fixed database roles.

#### **Limitations**

* **Less robust datatype handling**: When enabled, `fast_executemany` may have less robust handling of certain datatypes, which can lead to issues. Due to these limitations and thorough testing to ensure compatibility with the data is advised.

#### **Recommendations**

* **Performance testing**: Before enabling this feature in a production environment, perform extensive testing to ensure that it does not adversely affect data integrity or application performance.

## Supported data types

The below table indicates what's supported per generator type, and if any additional processing is performed by Syntho to successfully generate and write the data.

| Data Type        | AI-powered Generation                                                                                                      | Mockers                                                                                                          | Mask                                                                                                          | Calculated Columns                                                                                                               | Other                                      |
| ---------------- | -------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------ |
| BIT              | False                                                                                                                      | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/other)           | False                                                                                                         | False                                                                                                                            | -                                          |
| TINYINT          | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#discrete)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| SMALLINT         | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#discrete)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| INT              | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#discrete)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| BIGINT           | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#discrete)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-integer) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| NUMERIC          | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| DECIMAL          | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| FLOAT            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| REAL             | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| DATE             | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#datetime)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/datetime)        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/datetime)        | False                                                                                                                            | -                                          |
| TIME             | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#datetime)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/datetime)        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/datetime)        | False                                                                                                                            | -                                          |
| DATETIME         | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#datetime)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/datetime)        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/datetime)        | False                                                                                                                            | -                                          |
| DATETIME2        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#datetime)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/datetime)        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/datetime)        | False                                                                                                                            | -                                          |
| SMALLDATETIME    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#datetime)    | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/datetime)        | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/datetime)        | False                                                                                                                            | -                                          |
| DATETIMEOFFSET   | True\*                                                                                                                     | True\*                                                                                                           | True\*                                                                                                        | True\*                                                                                                                           | -                                          |
| CHAR             | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| NCHAR            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| VARCHAR          | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| NVARCHAR         | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| TEXT             | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| NTEXT            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#categorical) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/text)            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| BINARY           | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | -                                          |
| VARBINARY        | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | -                                          |
| IMAGE            | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | -                                          |
| MONEY            | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| SMALLMONEY       | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/ai-powered-generation#continuous)  | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/numeric-decimal) | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/calculated-columns#supported-data-types) | -                                          |
| UNIQUEIDENTIFIER | False                                                                                                                      | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/other)           | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mask/uuid)            | False                                                                                                                            | -                                          |
| ROWVERSION       | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | Completely excluded from writing           |
| TIMESTAMP        | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | Completely excluded from writing           |
| XML              | False                                                                                                                      | False                                                                                                            | False                                                                                                         | False                                                                                                                            | XMLs are written as `<blank>blank</blank>` |
| SQL\_VARIANT     | False                                                                                                                      | True\*                                                                                                           | True\*                                                                                                        | True\*                                                                                                                           | -                                          |
| HIERARCHYID      | False                                                                                                                      | True\*                                                                                                           | True\*                                                                                                        | True\*                                                                                                                           | -                                          |
| GEOMETRY         | False                                                                                                                      | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/other)           | False                                                                                                         | False                                                                                                                            | -                                          |
| GEOGRAPHY        | False                                                                                                                      | [True](https://docs.syntho.ai/configure-a-data-generation-job/configure-column-settings/mockers/other)           | False                                                                                                         | False                                                                                                                            | -                                          |

{% hint style="info" %}
**\***&#x53;ome data types are not actively supported; however, certain generators such as AI synthesize, mask, mockers, or calculated columns may still show 'True' for these fields. This means the generators can be applied, even though the types are not actively supported. Duplication is fully supported for these data types.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.syntho.ai/setup-workspaces/create-a-workspace/connect-to-a-database/microsoft-sql-server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
