본문으로 건너뛰기
Skillpedia
데이터베이스40k · #7435

sql-server-table-reconciliation

하는 일

이 도구는 두 SQL Server 데이터베이스에 있는 같은 테이블을 비교해 차이를 찾습니다. 누락된 행, 열 데이터의 차이, 테이블 구조의 변경을 확인합니다.

사용하는 경우

  • ✓마이그레이션 후 데이터를 검증할 때.
  • ✓운영 환경과 스테이징 환경을 비교할 때.
  • ✓자동 데이터 업데이트 과정(ETL)이 예상대로 작동했는지 확인할 때.

스킬 링크

https://github.com/github/awesome-copilot/blob/main/skills/sql-server-table-reconciliation/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/github/awesome-copilot/blob/main/skills/sql-server-table-reconciliation/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“운영 서버와 스테이징 서버의 'Customers' 테이블과 'Orders' 테이블을 비교해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

두 SQL Server 데이터베이스의 연결 정보와 테이블 이름을 제공합니다. 도구는 데이터를 효율적으로 추출하고, 고유 식별자를 기준으로 행 단위로 비교합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 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

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 == 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

Scenario Strategy
< 100K rows Single Arrow fetch, in-memory pandas compare

…

자주 묻는 질문

기본 키(primary key)란 무엇인가요?

테이블에서 각 행을 고유하게 식별하는 열(또는 열의 조합)입니다. 사람의 주민등록번호나 판매의 주문 번호와 같습니다.

아주 큰 테이블은 어떻게 처리하나요?

데이터를 덩어리(배치) 단위로 처리하거나, 각 행의 요약 코드(해시)를 만들어 먼저 비교합니다. 이 방법이 훨씬 빠릅니다.

데이터가 다르면 어떻게 되나요?

어떤 행이나 열이 다른지, 또는 한 서버에만 있는 행이 무엇인지 보여 주는 보고서를 만듭니다.

상세 정보

작성자의 원본 설명

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

인기도

GitHub 스타
40k
순위
#7435
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬