Search docs.molo17.com
    Configuration guide Connectors

    Prepare a SQL Server target so snapshots and CDC run without truncation or type errors

    Most problems on a SQL Server target come from the table, not from Gluesync: a column that is narrower than the source data, a type that cannot hold the value, a collation that treats two keys as one, or a database user that may write rows but not create a table. This guide shows how to give Gluesync the right permissions, let it create the table with the right types or check one you created yourself, find the column behind String or binary data would be truncated, and fix the type, reserved-word and collation problems that show up later.

    In this guide

    You will learn how to grant the SQL Server user only what Gluesync needs, create the target table from the Field mapping dialog with the right lengths, compare a table you created yourself with the source, find and fix a truncated column without restarting the entity, resolve the type pairs that the dialog marks as incompatible with a field function or a UDF, check that reserved words such as order, user, key and group work as column names, and decide how keys that differ only by case, accents or trailing spaces behave. A type mapping table and a symptom, cause and fix table close the guide.

    Quick information

    Goal

    Replicate to SQL Server without truncation, overflow, conversion, permission or duplicate-key errors, and know where each one comes from

    Audience

    Data engineers and database administrators who own a SQL Server target

    Level

    Intermediate

    Time required

    About 60 minutes

    Area

    Control Plane → Pipelines → Entities → Field mapping; entity page → Compare DDL; SQL Server → T-SQL

    Applies to

    Gluesync 2.3

    Before you begin

    Make sure that:

    1. A pipeline already has a source that Core Hub can read, for example PostgreSQL, and a MS SQL Server target whose connection works. This guide was tested with a PostgreSQL source and SQL Server 2022 as the target;

    2. You can sign in to the Control Plane with a role that can edit pipelines, and you can run T-SQL on the target database with an administrative login;

    3. The source tables you want to replicate exist. The target tables may or may not exist yet: both cases are covered;

    4. You know which database, schema and user the target connection uses. This guide uses the database gsdemo, the schema demo and the user gluesync_writer.

    The T-SQL in this guide is plain SQL Server syntax and works in any client, for example Query Studio on the target connection, sqlcmd or SQL Server Management Studio. The error texts quoted here were captured on SQL Server 2022. The messages that name the column (String or binary data would be truncated in table …​, column …​) are produced by SQL Server itself: older versions of SQL Server can return the same error without the table and column, and then the comparison in step 5 is the way to find the column.

    Guide steps

    Optional: create the example tables

    SQL

    Skip this step if you already have your own tables and pipeline. It creates the source and target objects that the next steps use, with columns that are deliberately hard to map.

    1. On the source PostgreSQL database, run:

      CREATE SCHEMA mt_demo;
      
      CREATE TABLE mt_demo.customers_demo (
        id integer PRIMARY KEY, name varchar(100), notes text, ref uuid,
        payload jsonb, photo bytea, credit numeric(12,2),
        created_at timestamp, active boolean);
      INSERT INTO mt_demo.customers_demo VALUES
        (1,'Acme Spa','first notes','2f8c7d2e-6b1a-4c5e-9d0f-1a2b3c4d5e6f',
         '{"tier":"gold"}','\xdeadbeef',1500.50,'2026-10-28 10:00:00',true);
      
      CREATE TABLE mt_demo.trunc_demo (
        id integer PRIMARY KEY, name varchar(200), note text, city varchar(30),
        price numeric(12,2), big bigint, born timestamp, active boolean);
      INSERT INTO mt_demo.trunc_demo VALUES
        (1,'Short name','short note','Rome',10.50,100,'2026-01-01 10:00:00',true);
      
      CREATE TABLE mt_demo.reserved_demo (
        id integer PRIMARY KEY, "order" integer, "user" varchar(50),
        "key" varchar(50), "group" varchar(50), "begin" varchar(50), "my col" varchar(50));
      INSERT INTO mt_demo.reserved_demo VALUES (1,10,'alice','k1','g1','b1','m1');
      
      CREATE TABLE mt_demo.case_demo (code varchar(30) PRIMARY KEY, label varchar(60));
      INSERT INTO mt_demo.case_demo VALUES ('abc','lower'),('ABC','upper'),('ábc','accent');
    2. On the target SQL Server, create the database and the schema, and a table that is narrower than the source on purpose:

      CREATE DATABASE gsdemo COLLATE SQL_Latin1_General_CP1_CI_AS;
      GO
      USE gsdemo;
      GO
      CREATE SCHEMA demo;
      GO
      CREATE TABLE demo.trunc_demo (
        id int NOT NULL PRIMARY KEY,
        name varchar(30) NULL, note varchar(100) NULL, city nvarchar(30) NULL,
        price numeric(6,2) NULL, big int NULL, born datetime NULL, active bit NULL);
      CREATE TABLE demo.reserved_demo (
        id int NOT NULL PRIMARY KEY,
        [order] int NULL, [user] varchar(50) NULL, [key] varchar(50) NULL,
        [group] varchar(50) NULL, [begin] varchar(50) NULL, [my col] varchar(50) NULL);
      CREATE TABLE demo.case_demo (code varchar(30) NOT NULL PRIMARY KEY, label varchar(60) NULL);
    Expected result

    The source schema mt_demo holds four tables, and the target database holds the schema demo with three tables. The table customers_demo has no target table yet: step 3 creates it from the Control Plane.

    Give the SQL Server user the permissions Gluesync needs

    SQL

    The target page asks for a user that can read and write the target tables. That is enough only when every target table already exists and the entity never truncates it. Each extra capability below is needed for one thing, and missing it produces one specific error.

    1. Connect to the target database as an administrator and create the user:

      USE gsdemo;
      CREATE LOGIN gluesync_writer WITH PASSWORD = '<a strong password>';
      CREATE USER gluesync_writer FOR LOGIN gluesync_writer;
      ALTER ROLE db_datareader ADD MEMBER gluesync_writer;
      ALTER ROLE db_datawriter ADD MEMBER gluesync_writer;
    2. If Gluesync creates tables for you (step 3), grant the right to create a table and to use the schema:

      GRANT CREATE TABLE TO gluesync_writer;
      GRANT ALTER ON SCHEMA::demo TO gluesync_writer;
    3. If you turn on bulk operations (Use bulk operations during CDC or Use bulk operations during Snapshot), Gluesync keeps its staging tables in a schema named gluesync. Create it once, owned by the same user, so that Gluesync does not need the right to create schemas:

      CREATE SCHEMA gluesync AUTHORIZATION gluesync_writer;
    4. In the Control Plane, set this user as Username of the MS SQL Server target connection.

    The same grant also covers the truncate that precedes a snapshot that inserts rows.

    Expected result

    db_datareader and db_datawriter let entities read and write existing tables. GRANT CREATE TABLE plus GRANT ALTER ON SCHEMA::demo let the wizard in step 3 create a table. The schema gluesync exists before the first bulk write.

    Each missing permission has its own symptom. All of them were reproduced by removing one grant at a time:

    What you see Missing permission Grant

    The table is not created, and the error says CREATE TABLE permission denied in database 'gsdemo'.

    CREATE TABLE on the database

    GRANT CREATE TABLE TO gluesync_writer;

    The same message, now The specified schema name "demo" either does not exist or you do not have permission to use it.

    ALTER on the target schema

    GRANT ALTER ON SCHEMA::demo TO gluesync_writer;

    Entity Upsert Failed with User does not have permission to perform this action. when you save an entity with bulk operations on

    The user cannot create the gluesync schema

    CREATE SCHEMA gluesync AUTHORIZATION gluesync_writer;

    A snapshot that inserts rows fails with Cannot find the object "case_ci" because it does not exist or you do not have permissions. (SQL Server error 1088)

    TRUNCATE TABLE needs ALTER on the table or its schema

    GRANT ALTER ON SCHEMA::demo TO gluesync_writer;

    Let Gluesync create the table and choose the right types

    UI

    Use this step when the target table does not exist. If you created the table yourself, go to step 4.

    1. In the Control Plane, open the pipeline and select Entities (the blue button with the plus sign above the entity list). The Add entities page opens with the Object browser;

    2. Expand the source schema, for example mt_demo, and select the check box of the table customers_demo. The Field mapping dialog opens;

    3. In Target Schema select demo;

    4. In Target Table type customers and select Create table "customers". The banner New table customers will be created on confirm. appears and every source column gets a proposed target type;

    5. Look at the Length column. The cells of notes, ref, payload and photo show 0 with a red mark, the banner says Missing required field and Confirm is disabled.

    Field mapping dialog creating the table customers
    Figure 1. The proposal for text, uuid, jsonb and bytea has no length (1), so the dialog cannot be confirmed.
    1. For each of the four columns, open the Target type list and choose the SQL Server type from the type mapping table in this guide: nvarchar with Length -1 for notes and payload, uniqueidentifier for ref, and varbinary with Length -1 for photo. A length of -1 means MAX;

    2. Check that the Error tab reads Error (0), then select Confirm.

    Field mapping dialog with notes and payload as nvarchar -1
    Figure 2. The four columns now have a real type (1) and Confirm (2) is enabled.
    1. A second dialog, Create table customers, shows the exact statement. Read it, then select Create table customers. Select Copy snippet instead if your DBA must run the statement.

    Create table customers dialog with the read-only CREATE TABLE statement for the demo.customers table
    Figure 3. Review the generated CREATE TABLE (1); Copy snippet (2) copies it for a manual run.
    1. Select Confirm and continue to save the entity.

    Expected result

    The table exists with the types you chose. In T-SQL, SELECT c.name, t.name AS type, c.max_length FROM sys.columns c JOIN sys.types t ON t.user_type_id = c.user_type_id WHERE c.object_id = OBJECT_ID('demo.customers') returns name as varchar 100, notes and payload as nvarchar -1, ref as uniqueidentifier, photo as varbinary -1, credit as numeric, created_at as datetime2 and active as bit.

    Do not accept the proposal blindly. The wizard proposes text for a PostgreSQL text column, and no length for uuid, jsonb, json, arrays and bytea, which the dialog refuses until you choose one. text is a deprecated SQL Server type: prefer varchar(max) or nvarchar(max). The type mapping table at the end of this guide lists a choice for every common source type.

    Check a table you created yourself against the source

    UI + SQL

    Use this step when the target table already exists, or after step 3 to double-check it.

    1. In the Field mapping dialog choose the existing table in Target Table instead of Create table;

    2. Open the Error and Warning tabs. Each entry is a source and target type that do not fit, and the dialog cannot be confirmed while the Error tab is not empty (step 7 explains how to clear it);

    3. For lengths, which the dialog does not judge, list the real target widths in T-SQL:

      SELECT c.name AS col, t.name AS type,
             CASE WHEN c.max_length = -1 THEN 'MAX'
                  WHEN t.name IN ('nvarchar','nchar') THEN CAST(c.max_length/2 AS varchar(10))
                  ELSE CAST(c.max_length AS varchar(10)) END AS length_in_chars,
             c.precision, c.scale
      FROM sys.columns c JOIN sys.types t ON t.user_type_id = c.user_type_id
      WHERE c.object_id = OBJECT_ID('demo.trunc_demo') ORDER BY c.column_id;
    4. On the source, list the longest value of each text column and the largest number of each numeric column. For PostgreSQL:

      SELECT max(length(name)) AS name_chars, max(length(note)) AS note_chars,
             max(octet_length(note)) AS note_bytes, max(price) AS max_price
      FROM mt_demo.trunc_demo;
    5. Compare the two results column by column. Every target column must be at least as wide as the longest source value, with room to grow, and every numeric target must have at least the source precision and scale.

    Expected result

    For the example table, the source returns name_chars 80 and note_chars 150, and the target has name varchar(30) and note varchar(100): both are too narrow, and price numeric(6,2) cannot hold 99999.99. These are the columns to widen before you start the entity.

    nvarchar(n) counts characters in pairs of bytes (UTF-16 code units), not in bytes: nvarchar(30) has a max_length of 60. The Compare DDL dialog (step 5) prints that byte count, so an nvarchar(30) column appears there as nvarchar(60).

    Find the column behind "String or binary data would be truncated" and fix it

    UI + SQL

    A target table that is too narrow works for weeks and then fails when the first longer value arrives. Reproduce it with the table from step 1.

    1. Create an entity from mt_demo.trunc_demo to the existing demo.trunc_demo and start it with change data capture (CDC). Then, on the source, insert a long value:

      INSERT INTO mt_demo.trunc_demo (id, name, note)
      VALUES (40, 'Order 40', repeat('long note ', 15));
    2. Open the entity. A red banner Target write failed names the table and the column, and shows the value that did not fit. Select Copy error to copy it, or View notifications for the notification String or binary data found truncated.

    Entity page in error with the Target write failed banner marked 1
    Figure 4. The banner (1) names the table and the column; Copy error (2) copies the text; Compare DDL (3) opens the next dialog.
    1. Select Compare DDL. The source CREATE TABLE is on the left and the target on the right. The row of the column in the error is the one where the target is shorter, here note text against note varchar(100).

    Compare table DDL dialog with the source column note text marked 1 and the target column note varchar(100) marked 2
    Figure 5. The same column in the source (1) and in the target (2).
    1. Widen the column in SQL Server, to the longest source value with room to grow, or to MAX:

      ALTER TABLE demo.trunc_demo ALTER COLUMN note varchar(300) NULL;
    2. Do not restart anything. Wait a few seconds and check the row:

      SELECT id, len(note) AS l FROM demo.trunc_demo WHERE id = 40;
    Expected result

    The entity retries on its own and the error clears: the query returns 40 with l 149, and the entity is back to Active. The same happened when a name column was widened from varchar(30) to varchar(200): the rows that had failed arrived without a restart or a new snapshot.

    If you cannot or do not want to widen the column, the other ways out are to shorten the value in transit with a UDF (there is no built-in function that shortens text), or to filter the long rows out with data filters.

    If the message does not name a column, for example on an older SQL Server, run the two queries of step 4 and compare the widths, as there. Characters that need two code units count twice: ten emoji do not fit in nvarchar(10) (the error shows 😀😀😀😀😀 as the truncated value), and ten é do not fit in a varchar(10) column with a UTF-8 collation, because each takes two bytes.

    Changing the mapping from the Control Plane (Edit mapping, then Confirm) is a different operation: it stops the entity with the warning Entity Configuration Changed and asks for a new resync. Widening a column in SQL Server does not.

    Fix overflow and conversion errors that are not about text

    SQL

    Three more value errors look like truncation but are not. They were reproduced on the same table, one value at a time.

    1. For a number that does not fit, for example inserting 99999.99 into price numeric(6,2), the notification reads Arithmetic overflow error converting numeric to data type numeric. Widen the column:

      ALTER TABLE demo.trunc_demo ALTER COLUMN price numeric(12,2) NULL;
    2. For a bigint source and an int target, inserting 9000000000 gives Arithmetic overflow error converting expression to data type int. Use bigint:

      ALTER TABLE demo.trunc_demo ALTER COLUMN big bigint NULL;
    3. For a timestamp source and a datetime target, a date before 1753 gives Batch Update with The conversion of a datetime2 data type to a datetime data type resulted in an out-of-range value. (SQL Server error 242). Use datetime2, which also keeps microseconds:

      ALTER TABLE demo.trunc_demo ALTER COLUMN born datetime2(6) NULL;
    Expected result

    After each ALTER, the entity writes the rows that were waiting. Rows rejected earlier arrive without a new snapshot when the entity stays in CDC; if the error came from a snapshot, run the snapshot again.

    Clear the type pairs that the dialog marks as incompatible

    UI

    When you point an entity at a table you created, the Field mapping dialog compares the type of every source and target column. The comparison below is for a source table with 29 typed columns mapped to a target table whose types were chosen on purpose to be wrong.

    Source to target Dialog shows What it means

    integer to varchar, boolean to varchar(5), numeric to varchar, date to varchar, timestamp to varchar, time to varchar, bytea to varchar(max)

    Error (red)

    Needs a field function that turns the value into text (below)

    text to int, text to datetime2, text to date, text to bit, text to varbinary(max), boolean to int, integer to bit, timestamp to date, date to datetime2

    Error (red)

    Needs a field function or a UDF

    integer to decimal, numeric to int, timestamptz to datetime2(7), integer to bigint, bigint to int, double precision to decimal

    Warning (yellow)

    Written, but bigint to int overflows for a value above 2,147,483,647

    uuid to uniqueidentifier, uuid to varchar(36), jsonb to nvarchar(max), text to nvarchar, text[] to nvarchar(max), timestamp to datetime

    No mark

    Written; a timestamp earlier than 1753 still fails on datetime, see step 6

    text to uniqueidentifier

    No mark

    Written while every value is a valid GUID; Conversion failed when converting from a character string to uniqueidentifier for the first one that is not

    The Error and Warning tabs list the pairs. Apply a field function to each red pair:

    1. Select the fx button at the end of the target row;

    2. Open Functions collection and choose the function that produces the target type: Convert Int to String for integer to varchar, Convert Boolean to String (true/false) for boolean to varchar, Convert Date and Time to String and Convert Date to String (both with a pattern) for timestamp and date, Convert Decimal to String for numeric to varchar, Convert String to Boolean for text to bit, Convert String to Date (with a pattern) for text to date, String to Byte Array (charset UTF-8) for text to varbinary, and Convert String to Decimal for text to a decimal column;

    3. Repeat for every red row, then select Confirm.

    Field mapping dialog where five rows have a field function marked 1
    Figure 6. Five rows now carry a function (1) and moved from error to warning. The row that no built-in function fits (2) keeps Confirm (3) disabled.

    A built-in function cannot return the wrong type: Convert String to Decimal is refused for an int column with the message Field function STRING_TO_BIG_DECIMAL returns BIG_DECIMAL, but target column 't_int' is INT. A text value that must become an int therefore needs a UDF, written as in Write and test a UDF to convert dates, times, and names, or a decimal(10,0) target column. Without either, the dialog stays red, and a non-numeric value that arrives later fails with Conversion failed when converting the nvarchar value 'abc' to data type int. (SQL Server error 245).

    Expected result

    The rows that carry a function moved from the Error tab to the Warning tab. In a test run that applied the same functions, a snapshot wrote 42 as '42', true as 'true', 2026-10-28 as '2026-10-28' and 12.50 as '12.50' into the varchar columns, and the text values 'true', '2026-10-28', 'hello' and '12.50' into bit, date, varbinary and decimal(10,2) columns as 1, 2026-10-28, hello (as bytes) and 12.50.

    Check that reserved words work as column names

    UI + SQL

    Words such as order, user, key, group, check, begin, select and table are reserved in SQL Server. A statement that writes them without brackets fails with Incorrect syntax near the keyword, and that error appears on one statement type only: an older build bracketed the columns in the snapshot INSERT and the CDC INSERT and UPDATE, but not the key columns of the CDC DELETE. Gluesync 2.3 brackets every column name.

    1. Create an entity from mt_demo.reserved_demo to the existing demo.reserved_demo, and start it with a snapshot;

    2. On the source, run an insert, an update and a delete:

      INSERT INTO mt_demo.reserved_demo VALUES (2,20,'bob','k2','g2','b2','m2');
      UPDATE mt_demo.reserved_demo SET "order" = 11, "begin" = 'b1-upd' WHERE id = 1;
      DELETE FROM mt_demo.reserved_demo WHERE id = 2;
    3. On the target, read the table:

      SELECT * FROM demo.reserved_demo ORDER BY id;
    Expected result

    The target holds one row: id 1, order 11, user alice, key k1, group g1, begin b1-upd, my col m1. The snapshot, the update and the delete all worked, also with Use bulk operations during CDC on. A column with a space in its name works as well. The same holds when the key column itself is a reserved word: a table with the primary key order replicated an insert, an update and a delete.

    If the failing statement in your logs shows a bare reserved word and the error Incorrect syntax near the keyword, you run a build that is older than 2.3: upgrade. You can reproduce the failure by hand: DELETE FROM demo.reserved_demo WHERE (begin = 'x') fails, DELETE FROM demo.reserved_demo WHERE ([begin] = 'x') does not.

    A column name that contains a closing bracket, such as a]b, is not escaped in the snapshot statement. The snapshot stops with Incorrect syntax near 'b'. Rename the column in the source, or replicate from a view that renames it.

    Decide how keys that differ by case, accents or spaces behave

    SQL + UI

    SQL Server compares keys with the collation of the key column. The default collation of the example database, SQL_Latin1_General_CP1_CI_AS, is case insensitive and accent sensitive, so the key values abc and ABC are the same key, while abc and ábc are not. A PostgreSQL source treats all three as different keys.

    1. Create an entity from mt_demo.case_demo to demo.case_demo and run a snapshot. On the target, read it:

      SELECT code, label FROM demo.case_demo;
    2. To keep all three keys, make the key column case sensitive. Drop the primary key, change the collation and add the key again, then delete the entity and add it again so that Gluesync reads the new collation:

      DECLARE @pk sysname = (SELECT name FROM sys.key_constraints
                             WHERE parent_object_id = OBJECT_ID('demo.case_demo') AND type = 'PK');
      EXEC('ALTER TABLE demo.case_demo DROP CONSTRAINT ' + @pk);
      ALTER TABLE demo.case_demo ALTER COLUMN code varchar(30) COLLATE Latin1_General_100_CS_AS NOT NULL;
      ALTER TABLE demo.case_demo ADD CONSTRAINT PK_case_demo PRIMARY KEY (code);
      DELETE FROM demo.case_demo;
    3. Run the snapshot of the new entity and read the table again.

    Expected result

    With the case-insensitive key, the snapshot copies two of the three rows, abc with lower and ábc with accent: Gluesync detects the case-insensitive key collation when the entity is created and drops the duplicate ABC row without an error. With the case-sensitive key, all three rows arrive. Editing the mapping of the existing entity and confirming did not change this behavior; creating the entity again did.

    Two more differences between SQL Server and the source do not depend on the collation:

    • A trailing space is ignored when SQL Server compares strings, so the keys abc and abc ` are the same key even with a case-sensitive collation. A snapshot that inserts both stops with `Violation of PRIMARY KEY constraint …​ The duplicate key value is (abc )., and in CDC the row abc ` overwrites the row `abc instead of adding one;

    • Text is stored with the code page of the column. A varchar column with a non-UTF-8 collation changes the characters it cannot hold: Łódź ĄĘ was stored as Lódz AE, and Russian and Japanese text as ?????? and ???, with no error. An nvarchar column, or a varchar column with a _UTF8 collation, stores all of them. The columns created by the wizard take the collation of the database, so use nvarchar for text that is not Western European.

    Expected result

    Selecting CAST(name AS nvarchar(50)) from the three test columns returns Lódz AE, ?????? and ??? for varchar with a CP1252 collation, and Łódź ĄĘ, Привет and 日本語 for nvarchar and for varchar with Latin1_General_100_CI_AS_SC_UTF8.

    Type mapping for a PostgreSQL source

    The first column is the source type. The second is what the Field mapping dialog proposes when it creates the table. The third is the type to choose.

    PostgreSQL source Wizard proposal Recommended SQL Server type Checked result

    integer, smallint, bigint, real, double precision

    int, smallint, bigint, real, float

    The proposal

    Values written unchanged

    varchar(n)

    varchar(n)

    varchar(n), or nvarchar(n) for non-Western text

    n must cover the longest value; see step 5

    char(n)

    varchar(n)

    char(n) if the padding matters

    With char(8), AB is stored as AB plus six spaces

    text

    text, with no length

    varchar(max) or nvarchar(max) (Length -1)

    Stored without limit; text and ntext are deprecated in SQL Server

    uuid

    varchar, with no length

    uniqueidentifier

    Stored as a GUID; SQL Server shows it in upper case

    json, jsonb

    json or varchar, with no length

    nvarchar(max)

    The JSON text is kept; jsonb is rewritten by PostgreSQL with a space after the colon. json is not a type on SQL Server 2022 (Cannot find data type json)

    bytea

    binary, with no length

    varbinary(max)

    The bytes are kept

    numeric(p,s)

    numeric(p,s)

    The proposal

    numeric(38,10) kept all digits; a smaller target overflows

    boolean

    bit

    bit

    true is 1

    timestamp(6)

    datetime2(6)

    datetime2(6)

    Microseconds kept; datetime rejects dates before 1753 and keeps only 3 ms

    timestamptz

    datetimeoffset(6)

    datetimeoffset(6)

    Stored in UTC: 10:11:12+02 arrives as 08:11:12 +00:00

    date, time

    date, time(6)

    The proposal

    Values written unchanged

    Arrays such as text[]

    varchar, with no length

    nvarchar(max)

    {a,b,c} arrives as a, b, c

    For other sources, the same rule applies: choose the SQL Server type from the value, not from the name of the source type, and check the Length column.

    Verify the result

    You have prepared the SQL Server target if:

    • The grants cover every capability the entities use, and the schema gluesync exists when bulk operations are on;

    • No Length cell in the Field mapping dialog shows 0, and the Error tab reads Error (0);

    • Every target text column is at least as wide as the longest source value, and every numeric target has at least the source precision and scale;

    • The target uses datetime2 for timestamps, nvarchar for non-Western text and uniqueidentifier, varbinary(max) and nvarchar(max) for uuid, bytea and JSON;

    • A snapshot and a CDC insert, update and delete of the entity finish without the Target write failed banner;

    • The number of rows of the source and the target agree, as in Find and fix row differences between source and target.

    Troubleshooting

    Problem Possible cause What to do

    Target write failed with String or binary data would be truncated in table '…​', column '…​'

    A value is longer than the target column, or needs more bytes than characters

    Compare the widths (steps 4 and 5) and ALTER COLUMN to a wider or MAX type. The entity recovers without a restart

    The same error, but the message names no column

    An older SQL Server does not report the column

    Run the width queries of step 4 on both sides, and compare

    Arithmetic overflow error converting numeric to data type numeric

    The target precision or scale is smaller than the source

    ALTER COLUMN to the source numeric(p,s)

    Arithmetic overflow error converting expression to data type int

    A bigint value in an int column

    Change the column to bigint

    Batch Update with datetime2 …​ to a datetime …​ out-of-range value

    A timestamp before 1753 in a datetime column

    Change the column to datetime2(6)

    Conversion failed when converting the nvarchar value '…​' to data type int

    A text source column mapped to a number column and a value is not numeric

    Fix the data, or write a UDF that returns null or a default for such values

    Implicit conversion from data type nvarchar to varbinary(max) is not allowed (error 257)

    A text source mapped to a varbinary column without a function

    Apply String to Byte Array (charset UTF-8) on the target column

    Incompatible data types banner and a disabled Confirm

    A source and target type pair that is not compatible

    Open the Error tab, apply a field function or a UDF to each row (step 7), or change the target type

    Missing required field when creating a table, with 0 in Length

    The proposal for text, uuid, json, arrays and bytea has no length

    Choose nvarchar or varbinary and Length -1, or uniqueidentifier

    Cannot find data type json when the table is created

    The proposed json type does not exist on SQL Server 2022

    Choose nvarchar with Length -1

    CREATE TABLE permission denied in database …​, or The specified schema name …​ either does not exist or you do not have permission to use it

    The user cannot create tables, or cannot use the target schema

    GRANT CREATE TABLE and GRANT ALTER ON SCHEMA::<schema> (step 2)

    Entity Upsert Failed with User does not have permission to perform this action.

    Bulk operations are on and the user cannot create the schema gluesync

    CREATE SCHEMA gluesync AUTHORIZATION <user> (step 2)

    Cannot find the object "…​" because it does not exist or you do not have permissions at the start of a snapshot

    The snapshot truncates the target table and the user lacks ALTER on it

    GRANT ALTER ON SCHEMA::<schema> (step 2)

    Incorrect syntax near the keyword 'order' (or user, key, group, begin)

    A reserved word written without brackets, by an older build

    Upgrade to Gluesync 2.3 and confirm with the test in step 8

    Incorrect syntax near 'b' for a column named a]b

    A closing bracket in a column name is not escaped

    Rename the column in the source, or replicate from a view

    Violation of PRIMARY KEY constraint …​ The duplicate key value is (abc )

    Two source keys are equal for SQL Server: abc ` and `abc, or abc and ABC with a case-insensitive collation

    Clean the keys in the source, or use a case-sensitive collation and add the entity again (step 9). A trailing space stays a duplicate in every collation

    Rows are missing on the target and there is no error

    Source keys that differ only by case collapsed into one on a case-insensitive key column

    Use a case-sensitive collation on the key column, then delete the entity and add it again (step 9)

    Lódz, ????? or ??? in a varchar column

    The collation of the column cannot store the characters

    Use nvarchar, or a _UTF8 collation, and run the snapshot again

    Contact MOLO17 Support if you need assistance with a SQL Server target.