GUID V4 - Random-Based Identifier (Recommended)
GUID v4 is the most widely used random-based identifier. Learn about its structure, collision probability, advantages and why it is recommended for general-purpose applications.
Generate GUIDs in SQL Server with built-in database functions such as NEWID() and NEWSEQUENTIALID(). When you are writing queries or defaults, T-SQL is the usual way to work with those values.
NEWSEQUENTIALID() is not GUID v7. It is a SQL Server-specific sequential GUID strategy, not the RFC 9562 time-ordered format.SQL Server generates random GUIDs with NEWID(). In practice, you usually call it from T-SQL in a query, default constraint, or stored procedure.
SELECT NEWID() AS GuidV4LikeValue;This is the standard SQL Server way to generate a random uniqueidentifier.
SQL Server exposes NEWSEQUENTIALID() for SQL Server-friendly ordered inserts. It is a database-specific sequential GUID feature, not RFC 9562 GUID v7.
CREATE TABLE dbo.Example
(
Id uniqueidentifier NOT NULL DEFAULT NEWSEQUENTIALID(),
Name nvarchar(100) NOT NULL
);Use NEWSEQUENTIALID() when you want SQL Server-friendly insert ordering, but do not document it as GUID v7.
SQL Server stores GUIDs as uniqueidentifier. When you need to convert between text and uniqueidentifier, you normally do it in T-SQL with TRY_CONVERT() or CONVERT().
DECLARE @guidText nvarchar(36) = '550e8400-e29b-41d4-a716-446655440000';
DECLARE @guid uniqueidentifier = TRY_CONVERT(uniqueidentifier, @guidText);
SELECT @guid AS ParsedGuid,
CONVERT(char(36), @guid) AS GuidText;Use TRY_CONVERT(uniqueidentifier, ...) when the input may be invalid and CONVERT(char(36), ...) when you need a string result in T-SQL.
NEWID() is the common random GUID generator.NEWSEQUENTIALID() improves locality but is not equivalent to GUID v7.uniqueidentifier.NEWSEQUENTIALID() is SQL Server-specific and improves insert locality, but it is not RFC 9562 GUID v7. If you document it as v7, you blur portability, interoperability, and ordering expectations across databases and application code.These articles expand on related concepts, formats and practical considerations.