Menu

SQL Server migration verification: matching row counts are only the start
πŸ“°

SQL Server migration verification: matching row counts are only the start

DEV Community: dotnetΒ·Martin PisacretaΒ·about 5 hours ago
#XgJPkfs6
#devtodotnet#devto#dev#rows#keys
Reading 0:00
15s threshold

After a SQL Server migration, matching row counts are a useful first check. They tell you that two tables contain the same number of rows. They do not tell you whether those rows contain the same values, or whether the destination contains the same primary keys. One missing row and one extra row can leave the total unchanged.

Smaller differences can also survive a count check: an accent removed from a name, a decimal changed from 12.50 to 12.51, or a NULL converted to empty text. The row still exists, but its content has changed. A useful acceptance report needs to distinguish missing rows, extra rows, and rows whose values differ under the same key.

Compare rows by their complete primary keys

The verifier described here is a small .NET 8 command-line tool for comparing selected tables between two SQL Server databases. It reads COUNT_BIG(*) and asks SQL Server to calculate a SHA-256 hash for each row.…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.