New to Claude Skills? Learn how to install them →

github on GitHub

SQL Server Table Reconciliation

OfficialFree

Efficiently compare SQL Server tables across instances.

by github37.7k stars on github/awesome-copilot
2 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What SQL Server Table Reconciliation does

SQL Server Table Reconciliation is a Python-based tool designed for developers and data engineers who need to compare identical tables across two SQL Server instances. This skill utilizes the mssql-python driver along with Apache Arrow for fast columnar data transfer, making it suitable for tasks such as data migration validation, ETL verification, and schema drift detection. By automating the comparison process, it helps ensure data consistency between production and staging environments.

The reconciliation process begins by collecting connection details for both the source and target SQL Server instances. Users specify the primary key or allow the tool to auto-detect it from the metadata. The skill then detects schema differences, extracts data using Arrow for efficient transfer, and compares both rows and columns. A detailed reconciliation report is generated, highlighting any discrepancies such as missing rows or column mismatches, which is crucial for maintaining data integrity.

This tool is particularly beneficial for teams involved in data management and migration projects, as it streamlines the process of validating data across environments. It supports various output formats, including console, CSV, and JSON, allowing users to choose how they want to view the results. The skill also includes optimization strategies for handling large tables, ensuring performance remains efficient even with extensive datasets.

Overall, SQL Server Table Reconciliation is a valuable addition for anyone needing to ensure data accuracy and consistency across SQL Server instances, making it easier to detect and resolve issues before they impact production systems.

When to use it

Use this tool when you need to validate data between production and staging environments or during data migrations.

When not to use it

This skill may not be suitable for non-SQL Server databases or for scenarios where schema comparison is not required.

What you can build with it

Data Migration Validation

Verify that data has been accurately migrated from a production SQL Server instance to a staging instance.

ETL Process Verification

Ensure that the ETL processes have not introduced discrepancies between source and target tables.

Schema Drift Detection

Identify any schema changes that may have occurred between two SQL Server instances over time.

How to install SQL Server Table Reconciliation

View source

1. Install with the skills CLI

npx skills add github/awesome-copilot/sql-server-table-reconciliation --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by github

SQL Server Table Reconciliation

Compare identical tables across two SQL Server instances using Python with mssql-python driver and Apache Arrow. Detect missing rows, column mismatches, schema drift, and produce a reconciliation report.

Workflow

  1. Collect connection details for source and target
  2. Identify primary key / composite key
  3. Detect schema differences
  4. Extract data via Arrow for efficient columnar transfer
  5. Compare rows and columns
  6. Generate reconciliation report

Collect Inputs

ParameterRequiredDescription
Source serverYesSource SQL Server (e.g. prod-server.database.windows.net)
Source databaseYesSource database name
Target serverYesTarget SQL Server (e.g. staging-server.database.windows.net)
Target databaseYesTarget database name
TablesYesComma-separated schema.table names, or schema.* wildcard (e.g. dbo.Orders,dbo.Items or dbo.*)
Auth modeYessql (user/password) or entra (Azure AD/token)
Primary keyAuto-detectColumn(s) forming the row identity. Auto-detect from metadata if not provided.
Columns to compareAllSubset of columns, or all non-PK columns
Chunk size100000Rows per batch for large tables
Output formatconsoleconsole, csv, parquet, or json

Bundled Script

The reconciliation logic is provided as a standalone script at scripts/reconcile.py. Invoke it with the appropriate arguments based on user inputs:

python scripts/reconcile.py \
    --source-server <source_server> \
    --source-database <source_database> \
    --target-server <target_server> \
    --target-database <target_database> \
    --tables "<table_spec>" \
    --auth <sql|entra> \
    --chunk-size <chunk_size> \
    --output <console|csv|json>

Optional arguments

ArgumentDescription
--primary-keyComma-separated PK column(s). Omit to auto-detect.
--columnsComma-separated columns to compare. Omit to compare all non-PK columns.

Example invocations

Single table with SQL auth:

python scripts/reconcile.py \
    --source-server prod-server.database.windows.net \
    --source-database ProdDB \
    --target-server staging-server.database.windows.net \
    --target-database StagingDB \
    --tables "dbo.Orders" \
    --auth sql \
    --output console

Wildcard with Entra auth and CSV output:

python scripts/reconcile.py \
    --source-server prod-server.database.windows.net \
    --source-database ProdDB \
    --target-server staging-server.database.windows.net \
    --target-database StagingDB \
    --tables "dbo.*" \
    --auth entra \
    --output csv

Prerequisites

Install required packages before running:

pip install mssql-python pyarrow pandas

Comparison Rules

  • Normalize types before comparing: cast decimals to same precision, trim strings, normalize datetime to UTC
  • NULL handling: NULL == NULL is considered a match (both sides missing = no diff)
  • Ignore row order: always compare by PK join, never positional
  • Large tables: chunk extraction with OFFSET/FETCH or ROW_NUMBER() partitioning

Hash-Based Optimization (for large tables)

When table has >1M rows, generate a hash pre-check:

SELECT {pk_cols},
       HASHBYTES('SHA2_256', CONCAT_WS('|', col1, col2, ...)) AS row_hash
FROM {table}

Compare hashes first; only fetch full rows for mismatched hashes. This reduces data transfer significantly.

Report Format

Reconciling dbo.EMPLOYEES...
Reconciling dbo.DEPARTMENTS...
Reconciling dbo.JOBS...

--- dbo.EMPLOYEES ---
  Source: 107  Target: 107
  Missing: 0  Extra: 0  Mismatches: 0
  Result: ✓ IDENTICAL

--- dbo.DEPARTMENTS ---
  Source: 27  Target: 27
  Missing: 0  Extra: 0  Mismatches: 3
  Result: ✗ DIFFERENCES FOUND

--- dbo.JOBS ---
  Source: 19  Target: 19
  Missing: 0  Extra: 0  Mismatches: 0
  Result: ✓ IDENTICAL

=== Summary: 2 passed, 1 failed, 0 skipped / 3 tables ===

When a single table is provided, include full detail (schema drift, sample rows, mismatches). When multiple tables, use the compact per-table format above with full detail only for tables with FAIL status.

Performance Considerations

ScenarioStrategy
< 100K rowsSingle Arrow fetch, in-memory pandas compare
100K–1M rowsChunked extraction (100K batches), streaming comparison
> 1M rowsHash pre-check → only fetch mismatched rows
Wide tables (100+ cols)Compare PK + hash first, drill into specific columns on mismatch
Network-constrainedUse Arrow columnar format (10-50x smaller than row-by-row)

Constraints

  • Always use mssql-python driver (not pyodbc, pymssql)
  • Always use Apache Arrow via cursor (cursor.arrow()) for data extraction
  • Connection MUST use connection string format, not keyword arguments (kwargs like encrypt=True throw errors)
  • Never compare without identifying PK first — ask user if auto-detect fails
  • Handle connection failures gracefully with retry logic
  • Never hardcode credentials in generated scripts — use os.environ / getpass (env vars: MSSQL_USER, MSSQL_PASSWORD)
  • Do not print credentials in output or logs
  • Use parameterized queries (? placeholders) for metadata lookups — never f-string interpolate user input into SQL

Frequently asked questions about SQL Server Table Reconciliation

Similar skills