sql-server-table-reconciliation
Compares SQL Server tables across different locations to validate data. It's useful for migrations, ETL checks, and detecting discrepancies.
What it does
This tool compares identical tables across two SQL Server databases to find differences. It checks for missing rows, differing column data, or changes in table structure.
When to use it
- ✓Validating data after a migration.
- ✓Comparing a production environment with a staging environment.
- ✓Ensuring automated data update processes (ETL) worked as expected.
Example of what to ask your AI
“Compare the 'Customers' and 'Orders' tables between the production and staging servers.”
Want more? Open the sections below.
How to use
The easiest way: copy the message below and paste it into Claude, ChatGPT, Cursor or any AI. It reads the skill and follows the instructions.
Skill link
Ready-to-paste message
How it works
You provide the connection details for both SQL Server databases and the table names. The tool efficiently extracts the data and compares it row by row, based on a unique identifier.
Installation
Easiest way: copy the skill link and paste it into Claude, ChatGPT or Cursor asking it to follow the instructions.
In the terminal (Claude Code, Codex, Cursor), in your project folder:
npx skills add github/awesome-copilot --skill sql-server-table-reconciliationOr download just the file:
curl -L https://raw.githubusercontent.com/github/awesome-copilot/main/skills/sql-server-table-reconciliation/SKILL.md -o SKILL.mdTechnical content (original SKILL.md)
Original text by the author, straight from 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
- Collect connection details for source and target
- Identify primary key / composite key
- Detect schema differences
- Extract data via Arrow for efficient columnar transfer
- Compare rows and columns
- Generate reconciliation report
Collect Inputs
| Parameter | Required | Description |
|---|---|---|
| Source server | Yes | Source SQL Server (e.g. prod-server.database.windows.net) |
| Source database | Yes | Source database name |
| Target server | Yes | Target SQL Server (e.g. staging-server.database.windows.net) |
| Target database | Yes | Target database name |
| Tables | Yes | Comma-separated schema.table names, or schema.* wildcard (e.g. dbo.Orders,dbo.Items or dbo.*) |
| Auth mode | Yes | sql (user/password) or entra (Azure AD/token) |
| Primary key | Auto-detect | Column(s) forming the row identity. Auto-detect from metadata if not provided. |
| Columns to compare | All | Subset of columns, or all non-PK columns |
| Chunk size | 100000 |
Rows per batch for large tables |
| Output format | console |
console, 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
| Argument | Description |
|---|---|
--primary-key |
Comma-separated PK column(s). Omit to auto-detect. |
--columns |
Comma-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 == NULLis considered a match (both sides missing = no diff) - Ignore row order: always compare by PK join, never positional
- Large tables: chunk extraction with
OFFSET/FETCHorROW_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
| Scenario | Strategy |
|---|---|
| < 100K rows | Single Arrow fetch, in-memory pandas compare |
…
FAQ
What is a primary key?
It's a column (or set of columns) that uniquely identifies each row in a table, like a social security number for people or an order ID for sales.
How does the tool handle very large tables?
It can process tables in chunks (batches) or generate a summary code (hash) for each row and compare these codes first, which is much faster.
What happens if data is different?
The tool generates a report showing which rows or columns have differences, or which rows exist on one server but not the other.
Details
Original description by the author
Use when: comparing SQL Server tables across instances, data migration validation, ETL verification, row mismatch detection, schema drift, reconciliation report, production vs staging comparison. Uses mssql-python driver with Apache Arrow for fast columnar data transfer and comparison.
repo: github/awesome-copilot
Popularity
- GitHub stars
- 40k
- Ranking position
- #5378
- License
- MIT
- Updated
- 10/15/2026
Comments
- …
More skills from this repository
acquire-codebase-knowledge
Helps your agent understand and document an existing code project. It's useful for onboarding new people or getting an overview of the architecture.
github/awesome-copilot
acreadiness-assess
Enables your agent to assess a project's readiness for AI and generate a report. It's useful for understanding how well a project is prepared to use AI tools.
github/awesome-copilot
acreadiness-generate-instructions
Helps your agent create instructions for AI tools based on an assessment. It's useful for improving how AI interacts with code and closing identified gaps.
github/awesome-copilot
acreadiness-policy
Enables your agent to help define or apply policies for AI project assessment. It's useful for standardizing how projects are evaluated and ensuring compliance.
github/awesome-copilot
Similar skills
clickhouse-io
Helps your agent optimize queries and schemas in ClickHouse databases. It applies best practices for high-performance analytical workloads. Use when analytical queries are too slow.
affaan-m/ECC
scientific-db-pubmed-database
Helps your agent search for scientific articles in the biomedical field. It's useful for research needing specific medical information.
affaan-m/ECC
scientific-db-uspto-database
Allows the agent to look up official US patent and trademark data. It's useful for intellectual property research.
affaan-m/ECC