SQL Tran Docs
  • Overview
    • About
    • Getting started
    • Object lifecycle
    • Why is there no AI inside?
    • Performance considerations
    • Security considerations
    • Assessment
    • Unlocking projects
    • Interface walk-through
    • Translation scenarios
    • Prerequisites for Azure Marketplace deployment
  • Emulation Scenarios
    • Emulation in SQL Tran
    • SQL Server to Fabric Warehouse
      • Data types
      • Case sensitivity
      • Cursors
        • Basic cursor loop
        • Cursor types
        • Fetch direction modes
        • Cursors in control flow
        • Nested cursors
        • Data modification cursors
        • Multiple cursors
        • Subqueries and filtering
      • Named procedure parameters
      • Result set limiting
      • MERGE statements
      • Computed columns
      • External tables
      • Identity columns
      • Default values
      • Sequences
      • Unsupported system objects
    • Synapse Analytics to Fabric Warehouse
      • Emulations
      • Limitations
    • SQL Server to Synapse Analytics
    • Oracle to PostgreSQL
  • Project wizard
    • Source database
    • Target database
    • Wrapping up
  • Projects
    • Project list
    • Overview
    • Workspace
    • Reports
    • Tests
    • Scratch pad
    • Settings
      • Project name
      • Mapping
      • Database connections
    • Navigation
    • Object complexity
    • Static analysis
    • Translation errors
    • Exporting and importing projects
  • Workspace
    • Object tree
    • Data lineage
    • Code
    • Actions
      • Overriding source
      • Overriding target
      • Ignoring objects
  • Tests
    • Workflow
    • Configure SQL Tran
    • Connecting to databases
      • Fabric Warehouse
      • Synapse Dedicated SQL Pool
      • Azure SQL Database, Azure SQL Managed Instance, Microsoft SQL Server
    • Tables
    • Views
    • Procedures
    • Functions
    • Triggers
    • Performance tests
  • Scripter
    • About
    • Supported databases
    • SQL Server
    • Azure SQL
    • Synapse Dedicated Pool
    • Oracle
    • PostgreSQL
    • MySQL
Powered by GitBook
On this page
  • Emulation context
  • Emulation strategy
  • Code example
  • Important notes
  1. Emulation Scenarios
  2. SQL Server to Fabric Warehouse

Identity columns

Emulation context

In Microsoft SQL Server, an identity column automatically generates sequential numeric values based on a defined seed and increment. Identity columns are commonly used to generate surrogate primary keys. They are declared using the IDENTITY(seed, increment) property in a CREATE TABLE statement, and values are typically assigned automatically during INSERT.

For example:

CREATE TABLE Customers (
    CustomerID INT IDENTITY(1,1) PRIMARY KEY,
    Name NVARCHAR(100)
);

Microsoft Fabric Warehouse does not support the IDENTITY property in table definitions. Fabric’s distributed architecture does not natively support database-managed auto-incremented values or automatic identity value generation. Identity logic must be implemented manually or externally during data loading. Microsoft’s documentation recommends alternatives such as using NEWID(), casting timestamps, or implementing custom sequence logic.

Due to this incompatibility, identity columns must be emulated or restructured when migrating from SQL Server to Fabric Warehouse.


Emulation strategy

SQL Tran removes the IDENTITY property from table definitions and replaces automatic value generation with explicit logic. The emulation process includes:

  • Replacing identity columns with standard INT or BIGINT columns marked NOT NULL.

  • Adding a /* SQLTRAN FIX: IDENTITY(...) */ comment to annotate the removed identity property.

  • Rewriting INSERT statements that omit the identity column to include explicitly generated values.

  • Introducing a local variable (e.g., @maxIdSqlTran) that stores the current maximum value in the target table.

  • Computing the next values manually using MAX(...) + N logic to emulate auto-increment behavior.


Code example

SQL Server:

CREATE TABLE Customers (
    CustomerID INT IDENTITY(1,1) PRIMARY KEY,
    Name NVARCHAR(100)
);

INSERT INTO Customers (Name)
VALUES ('Alice'), ('Bob');

Fabric Warehouse (generated by SQL Tran):

DECLARE @maxIdSqlTran INT;
CREATE TABLE Customers (
    CustomerID INT NOT NULL /* SQLTRAN FIX: IDENTITY(1,1) */  /* SQLTRAN FIX: PRIMARY KEY */,
    Name VARCHAR(200) /* SQLTRAN FIX: NVARCHAR(100) */
);

SELECT @maxIdSqlTran = ISNULL(MAX(CustomerID), 0)
FROM
	Customers;
INSERT
	INTO Customers ([CustomerID], Name)
	VALUES (@maxIdSqlTran + 1, 'Alice'), (@maxIdSqlTran + 2, 'Bob');
 /* SQLTRAN FIX: INSERT INTO Customers (Name)
VALUES ('Alice'), ('Bob'); */

Important notes

  • IDENTITY property removed: The IDENTITY(seed, increment) definition is stripped from the table and replaced with a standard column. A comment preserves the original declaration for reference.

  • Manual value generation injected: SQL Tran uses a MAX(...) + N pattern to emulate incremental identity values during insert. This preserves uniqueness but does not enforce database-side auto-incrementation.

  • Seed and increment ignored: SQL Tran does not honor the original seed and increment values. All computed values increment by 1 regardless of the original identity definition. This may lead to incorrect sequences if a custom increment was specified.

  • Explicit identity values preserved: When identity values are provided in source INSERT statements, SQL Tran does not modify the insert logic and preserves the original values.

  • Unsupported commands passed through: Statements like SET IDENTITY_INSERT ON/OFF are passed through unchanged, even though they are not supported in Fabric and may result in runtime errors. These must be removed or restructured manually.

  • Identity-returning functions not supported: SQL Server functions such as SCOPE_IDENTITY() and @@IDENTITY are not supported in Fabric. SQL Tran passes them through without rewriting. A diagnostic comment is emitted for SCOPE_IDENTITY(), but @@IDENTITY is not flagged. Logic relying on these functions must be manually replaced using Fabric-compatible techniques.

  • No sequence objects created: SQL Tran does not introduce SEQUENCE objects as a replacement for identity columns. If sequential ID generation is required via sequences, users must define and manage these manually.

  • Manual review required: Emulated identity logic should be reviewed to ensure it maintains expected sequencing, especially when custom seeds, increments, or pre-existing values are involved. Alternative strategies using Fabric-compatible mechanisms may be needed for large-scale ingestion.

PreviousExternal tablesNextDefault values

Last updated 5 days ago

Identity column emulation in SQL Tran