505a9d52a6ae7db8714c509e1764186c87ccb9dc
SQL Server Collation Migration (UTF-8 / UTF-16) – Data Copy + Verification
This repository contains two main scripts to support a SQL Server 2022 migration scenario:
- Data copy (Variant B / Checkpointing): copies data from a source database into a target database table-by-table with restart capability.
- Verification / compare script: compares source & target databases without comparing row contents (rowcounts + schema + programmable objects + principals).
Intended usage: build a new target DB (e.g. UTF-8 collation), deploy schema, run copy, then verify.
Repository layout
-
scripts/migrate_copy_checkpoint.sql
Copy data source → target (restartable, per-table commit, FK-aware order, live progress output) -
scripts/compare_source_target.sql
Compare source vs target (textual summaries + result sets)- Rowcounts per table
- Column schema diffs
- Views/Procs/Functions hash compare
- Trigger hash compare
- Users/Roles + Role memberships
-
docs/USAGE.md
How to run the migration copy safely. -
docs/VERIFY.md
How to run and interpret the compare results.
Quickstart
- Open SQL Server Management Studio (SSMS)
- Ensure target DB exists and schema is deployed
- Run:
scripts/migrate_copy_checkpoint.sql
- After successful copy, run:
scripts/compare_source_target.sql
Both scripts show live progress output in SSMS (Messages tab).
Configuration
At the top of each script set:
@SourceDb(defaultsysdb_UTF8)@TargetDb(defaultsysdb_utf8_jr)
Notes
- The copy script disables triggers, constraints, and nonclustered indexes in target during load and re-enables them afterwards.
- The compare script uses hashes (SHA2_256) for object definitions to quickly detect differences.
Description
Provides scripts to do generic collation migration. Copies source db contents to the migrated target database with the desired target collation. Plus script to verify contents and basic schema data.
54 KiB
0 Stars
1 Watchers
0 Forks