Randolph West digs into what a UNIQUEIDENTIFIER
looks like in storage:
Let’s take our example GUID again:
CC05E271-BACF-4472-901C-957568484405
. If we look at the table storage for this row, we’ll find it persisted as follows:0x71E205CCCFBA7244901C957568484405
(alternating octets are highlighted in bold).If you haven’t been following this series, this is a good place to remind you that SQL Server stores data using little-endian sequencing on disk and in memory. In the vast majority of cases, bytes are stored in reverse order because that’s how Intel CPUs like their data. However GUIDs are persisted slightly differently because of their sort order.
This is probably the most GUIDs I’ve seen in a single blog post.