Two shop tables merged into one: with INT keys the merge stops at Msg 2627 after 3 of 5 rows because both shops have orders 1 and 2, and with GUID keys all 5 rows arrive

Introduction to GUIDs: Merge Tables Without Key Clashes

An introduction to GUIDs starts with one problem: two tables that both count from 1. This post merges two small shop tables, first with INT keys and then with UNIQUEIDENTIFIER keys, and shows how to create, read and sort GUIDs. It also answers common reader questions: adding GUIDs, finding the newest row and getting the new key back. Every result comes from SQL Server 2025.

Read More