Skip to main content

Microsoft SQL Server (MSSQL)

Premium Connector

This connector requires the Standard Plan or higher.

Preparation​

To allow Shaped to connect to your MSSQL database, you need to create a read-only user and share those credentials through the Create Table endpoint.

You can create a read-only user on a MSSQL database with the following commands:

-- 1. Create a new login (server-level).
CREATE LOGIN [username] WITH PASSWORD = '[password]';

-- 2. Create a user (database-level) and map it to the login.
USE [database_name];
CREATE USER [username] FOR LOGIN [username];

-- 3. Grant read-only access by adding the user to the db_datareader role.
ALTER ROLE db_datareader ADD MEMBER [username];

-- 4. (Optional) Restrict access to specific tables instead of granting db_datareader role.
GRANT SELECT ON [schema].[table_name] TO [username];

Table Configuration​

Required fields​

FieldExampleDescription
schema_typeMSSQLSpecifies the connector schema type, in this case "MSSQL".
tablemoviesThe name of the table to sync.
useryour_userAccess account username.
passwordpAssw0rd1!Access account Password.
hostmy-mssql-db.xxxxxxx.us-east-2.rds.amazonaws.comDatabase hostname.
port1433Database port (the default for MSSQL is 1433).
databasemovielensThe name of the database that contains table to sync.
replication_keyupdated_atThe name of the column that contains a datetime key or ascending id for ordering data during incremental syncs.

Optional fields​

FieldExampleDescription
columns["productId", "color", "brand", "stockLevel"]The name of the columns you wish to sync from MSSQL into Shaped. If not specified, all columns will be synced.
unique_keys["productId"]Specify a list of columns that uniquely identify a row in the table, if duplicate rows are inserted with these keys, the latest row will be used.
batch_size100000The number of rows to fetch from the database in each batch, changing this can improve throughput for large tables. The default is 10000.

Table Creation Example​

Below is an example of a MSSQL table connector configuration:

name: your_mssql_dataset
schema_type: MSSQL
table: movies
user: your_user
password: pAssw0rd1!
host: my-mssql-db.xxxxxxx.us-east-2.rds.amazonaws.com
port: 3306
database: movielens
replication_key: updated_at

The following payload will create a MSSQL table and begin syncing data from Shaped using the Shaped CLI.

shaped create-table --file dataset.yaml