Understanding Microsoft GUIDs vs. RFC UUIDs: Architecture & Endianness
ITU-T Rec. X.667 / ISO/IEC 9834-8 & Microsoft Win32 GUID Specifications
Is a GUID Exactly the Same as a UUID?
In conceptual modern software engineering, GUID (Globally Unique Identifier) and UUID (Universally Unique Identifier) refer to the exact same underlying 128-bit identifier concept. However, deep within systems programming (specifically C++, Win32 APIs, and low-level byte serialization), there is a crucial architectural distinction: byte endianness.
RFC 4122 / 9562 UUID (Network Big-Endian)
Standard RFC UUIDs specify pure big-endian byte order (most significant byte first) across all 16 bytes. Java, Linux, Python, Go, and web standards read and transmit the byte stream sequentially from byte 0 through byte 15.
Microsoft Windows GUID (Mixed-Endian / Little-Endian)
Historically, the Win32 GUID C-struct was declared as struct GUID { unsigned long Data1; unsigned short Data2; unsigned short Data3; unsigned char Data4[8]; }. On x86/x64 processors, the first three integer fields are stored in little-endian byte order, while the final 8 bytes remain big-endian!
Common Microsoft GUID Formatting Specifiers
In .NET (C#, F#, VB.NET), calling guid.ToString(format) supports distinct output representations:
| Format Specifier | Example Output | Primary Target System |
|---|---|---|
| "D" (Default) | ca761232-ed42-11ce-bacd-00aa0057b223 | Standard hyphenated representation across APIs and web endpoints. |
| "B" (Braces / Registry) | {CA761232-ED42-11CE-BACD-00AA0057B223} | Windows Registry keys, COM Class IDs (CLSID), and Visual Studio project GUIDs. |
| "P" (Parentheses) | (CA761232-ED42-11CE-BACD-00AA0057B223) | Legacy ODBC configuration files and database scripts. |
| "N" (Number / Raw) | ca761232ed4211cebacd00aa0057b223 | Compact 32-character hexadecimal representation without hyphens. |
C# (.NET 9) and Microsoft SQL Server Implementation
using System;
// 1. Generate standard random GUID (UUID v4):
Guid id = Guid.NewGuid();
Console.WriteLine(id.ToString("B").ToUpper());
// Output: {6B29FC40-CA47-1067-B31D-00DD010662DA}
// 2. Parse existing GUID string:
Guid parsed = Guid.Parse("{6B29FC40-CA47-1067-B31D-00DD010662DA}");
bool isEmpty = (parsed == Guid.Empty);
-- 1. Create table with uniqueidentifier column:
CREATE TABLE Customers (
CustomerID UNIQUEIDENTIFIER DEFAULT NEWSEQUENTIALID() PRIMARY KEY,
FullName NVARCHAR(150) NOT NULL
);
-- Note: NEWSEQUENTIALID() prevents B-Tree index page splits
-- by creating sequentially increasing GUIDs per Windows boot cycle.