Skip to contentManaged Kafka is live: Apache Kafka on AWS for half the cost of MSK

Destinations

Connect Microsoft SQL Server as a destination

Create a SQL Server service account and connect it to Artie, so your pipeline creates and merges tables in the database and schema you choose.

Create a service account

Run these commands in your SQL Server client as a database admin. They create the login Artie connects with and grant it the permissions to create tables and merge data.

SQL
-- Create a service account
CREATE LOGIN artie_transfer WITH PASSWORD = 'PASSWORD';
GO

USE DATABASE_NAME;
GO

CREATE USER artie_transfer FOR LOGIN artie_transfer;
GO

-- If it's not dbo, change the schema name
GRANT ALTER ON SCHEMA::dbo TO artie_transfer;
GO

GRANT CREATE SCHEMA, CREATE TABLE, SELECT, INSERT, UPDATE, DELETE TO artie_transfer;
GO

Replace PASSWORD with the login’s password and DATABASE_NAME with the database Artie writes to. Run the GRANT ALTER ON SCHEMA statement once for each schema Artie writes to, including the staging schema if you set one.

Required settings

Enter the connection fields on the destination connector, then choose the database and schema on your pipeline’s destination.

FieldDefaultValue
HostNoneThe host name of your SQL Server instance, for example yourserver.database.windows.net.
Port1433The port SQL Server listens on.
UsernameNoneThe service account login, for example artie_transfer.
PasswordNoneThe service account password.
Database nameNoneThe database Artie writes to. Select one, or create one from the Dashboard.
Schema nameNoneThe schema Artie writes to. Select one, or create one from the Dashboard.

Creating a database from the Dashboard runs CREATE DATABASE as the service account, which the script above doesn’t allow. Select an existing database, or grant the login CREATE ANY DATABASE in master. On Azure SQL Database, add the login’s user in master to the dbmanager role instead.

If you set the schema name to public, Artie writes to dbo.

Schema layout

When your source has schemas, choose how Artie maps them. Pipeline setup labels the options One schema and Multiple schemas; pipeline settings label them Write to one schema and Write to multiple schemas.

  • One schema sends every table to the schema in Schema name.
  • Multiple schemas sends each table to a schema named after its source schema, with an optional prefix. Schema name isn’t used. Without a prefix, tables from a source schema named public land in dbo.

For how Artie names tables in each layout, see Destination table naming.

SSH tunnel

To reach a SQL Server instance in a private network, connect through an SSH tunnel.

Advanced settings

These destination settings apply to SQL Server. All three are off by default.

SettingLabel in pipeline settingsWhat it does
Staging schemaPut staging tables in a different schemaCreates Artie’s temporary staging tables in a separate schema.
Create missing schemasDynamically create namespacesCreates destination schemas that don’t exist, instead of failing verification on them.
Raw binaryWrite raw binary valuesWrites binary values as raw bytes in VARBINARY(MAX) columns instead of Base64 strings.

What Artie creates

Artie creates each destination table that doesn’t exist. When Artie merges data, it bulk copies the rows into a temporary staging table, then merges them into the destination table.

Staging tables sit in the destination table’s schema. When you set a staging schema, merges stage their tables there instead. Their names follow TABLE___artie_SUFFIX_EXPIRY. SUFFIX is 5 random characters, and EXPIRY is a Unix timestamp 6 hours after creation.

Column types

Artie creates columns with these SQL Server types.

Source valueSQL Server type
Integerbigint
Float or doublefloat
Decimal with precision up to 38NUMERIC(p, s)
Decimal with precision over 38, or no precisionVARCHAR(MAX)
BooleanBIT
String or UUIDVARCHAR(n) when the source column has a length, otherwise VARCHAR(MAX)
JSON object, array, or intervalNVARCHAR(MAX)
BinaryBase64 in a string column, or VARBINARY(MAX) with Raw binary on
DateDATE
TimeTIME
Timestamp without time zonedatetime2
Timestamp with time zonedatetimeoffset

String primary key columns are capped at VARCHAR(900), and binary primary key columns at VARBINARY(900).

Non-ASCII text in VARCHAR columns

Artie bulk copies VARCHAR values as UTF-8 bytes. A VARCHAR column with a non-UTF-8 collation reads those bytes as other characters, and counts the value as longer than it is. To avoid this, Artie stages most VARCHAR columns as NVARCHAR, and SQL Server converts the values when it writes the table.

These VARCHAR columns still receive UTF-8 bytes:

  • Primary key columns
  • Columns with a Japanese, Chinese or Korean collation
  • Columns whose collation Artie doesn’t know yet

NVARCHAR columns and VARCHAR columns with a _UTF8 collation aren’t affected.

Tables you create

Artie loads into tables you create yourself and keeps their column types. It reads these SQL Server types:

CategoryTypes
Textchar, varchar, nchar, nvarchar, text, ntext, xml, uniqueidentifier
Binarybinary, varbinary, image
Numerictinyint, smallint, int, bigint, decimal, numeric, money, smallmoney, float, real, bit
Date and timedate, time, datetime, datetime2, smalldatetime, datetimeoffset
Spatialgeography, geometry

A table with a column of any other type fails to load with the error unsupported data type.

Some of these types load differently:

  • nchar, nvarchar and ntext columns are staged as NVARCHAR.
  • xml columns are staged as NVARCHAR(MAX), and SQL Server converts the values to XML when Artie writes the table. SQL Server parses NVARCHAR values as UTF-16, so a value whose XML declaration names an encoding other than a 2-byte Unicode one, such as encoding="UTF-8", fails to convert. Artie doesn’t remove the declaration.
  • uniqueidentifier, money, smallmoney, geography and geometry columns are loaded through a staging table, and SQL Server converts the values. Spatial values from sources other than SQL Server are converted with STGeomFromWKB.
  • In merges, IDENTITY columns take the source’s values on insert, and Artie leaves them out of updates. Appends, such as history mode, leave them out, so SQL Server assigns them. SQL Server also fills an IDENTITY column the source doesn’t have.

Next steps

Was this page helpful?