Definition
A GUID (Globally Unique Identifier) is Microsoft’s name for a 128-bit unique identifier that follows the same standard as a UUID. The terms GUID and UUID are interchangeable in practice — both refer to a 128-bit number formatted as 32 hexadecimal digits in five hyphen-separated groups. Wikipedia’s GUID article covers the COM and Windows history in depth.
GUID is the preferred term in Windows documentation, the .NET System.Guid documentation, SQL Server, and COM/OLE. Outside those contexts, UUID is used almost universally.
Format
GUIDs use the same canonical string format as UUIDs:
6ba7b810-9dad-11d1-80b4-00c04fd430c8
8 - 4 - 4 - 4 - 12
The format is defined by RFC 9562 (2024), which supersedes the original RFC 4122. Microsoft’s implementation predates the RFC but conforms to it.
GUID vs UUID — the difference
There is no technical difference between a GUID and a UUID. The 128-bit structure, version bits, variant bits, and string representation are identical. The only difference is naming:
| Term | Primary context |
|---|---|
| UUID | IETF standard, Linux, macOS, most databases, most languages |
| GUID | Windows, .NET, SQL Server, COM, Microsoft documentation |
If someone sends you a GUID, you can use it anywhere a UUID is accepted, and vice versa.
SQL Server byte order
There is one important platform-specific quirk: SQL Server stores GUIDs in a non-standard byte order in the uniqueidentifier column type. The first three groups of the GUID are stored in little-endian byte order, while the last two groups are stored big-endian.
This means a UUID v7 generated by a standard library will not sort chronologically when stored in SQL Server’s uniqueidentifier type without a byte-swap transformation. If chronological sorting is important in SQL Server, either:
- Sort on a separate
datetime2column - Byte-swap the first 8 bytes before storing
- Use
NEWSEQUENTIALID()(SQL Server’s own sequential GUID function)
Other databases (PostgreSQL, MySQL) do not have this issue.
.NET and C#
In .NET, the System.Guid struct represents a GUID. You can generate one with:
Guid id = Guid.NewGuid();
Console.WriteLine(id); // e.g. 6ba7b810-9dad-11d1-80b4-00c04fd430c8
Guid.NewGuid() generates a v4 GUID (random). .NET 9 added Guid.CreateVersion7() for a time-ordered v7 GUID:
// .NET 9+
Guid id = Guid.CreateVersion7();
PowerShell
[System.Guid]::NewGuid().ToString()
# 6ba7b810-9dad-11d1-80b4-00c04fd430c8
COM and Windows internals
COM (Component Object Model) uses GUIDs extensively to identify interfaces (IID), classes (CLSID), and type libraries (LIBID). These GUIDs are registered in the Windows Registry and must be globally unique across all software, which is why the probabilistic uniqueness of 128-bit random identifiers is particularly valuable in this context.
Related terms
- UUID — the IETF standard name for the same identifier
- Variant — the bit field that identifies RFC 9562 UUIDs and GUIDs
- Collision — why the probability of two GUIDs being equal is negligible
Generate a UUID (or GUID) now with the UUID v7 generator or UUID v4 generator.
Frequently asked questions
What is the difference between UUID and GUID?
There is no technical difference. GUID (Globally Unique Identifier) is Microsoft's term for the same 128-bit standard. Both follow RFC 9562 and are interchangeable in all but name.
Does SQL Server use GUIDs or UUIDs?
SQL Server uses the term GUID and stores them in the uniqueidentifier column type (16 bytes). The values are compatible with standard UUIDs but SQL Server's internal byte order differs, which means UUID v7 does not sort chronologically as a uniqueidentifier without a byte-swap transformation.
What column type should I use to store a UUID in a database?
Use the native type where one exists — uuid in PostgreSQL, uniqueidentifier in SQL Server. In MySQL use BINARY(16) and store raw bytes. Avoid VARCHAR(36): it costs 36 bytes per row versus 16 for binary and makes every comparison a string operation.
Is a GUID the same as a UUID?
Yes — GUID (Globally Unique Identifier) is Microsoft's term for the same 128-bit value defined in RFC 9562. The .NET System.Guid struct and SQL Server's uniqueidentifier type both store the same 16-byte value. The terms are interchangeable in most contexts.
Why does SQL Server sort GUIDs differently from other databases?
SQL Server stores uniqueidentifier bytes in a non-standard order — the first three groups are stored little-endian. This means UUID v7 values, which are designed to sort chronologically, do not sort correctly in a SQL Server uniqueidentifier column without a byte-swap. NEWSEQUENTIALID() is SQL Server's own sequential GUID function that respects this byte order.
How do I generate a GUID in C# .NET?
Use Guid.NewGuid() for a random GUID (equivalent to UUID v4), or Guid.CreateVersion7() (available in .NET 9+) for a time-sortable UUID v7. Both return a System.Guid and are backed by the OS CSPRNG.