How to Generate GUIDs in SQL Server

Generate GUIDs in SQL Server with NEWID() for random values and use NEWSEQUENTIALID() only as a SQL Server-specific ordered alternative, not as RFC 9562 GUID v7.

Important: NEWSEQUENTIALID() is not GUID v7. It is a SQL Server-specific sequential GUID strategy, not the RFC 9562 time-ordered format.

How to generate random GUIDs in SQL Server

SELECT NEWID() AS GuidV4LikeValue;

This is the standard SQL Server way to generate a random uniqueidentifier.

How to generate time-ordered GUID alternatives in SQL Server

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.

Native support notes

  • SQL Server uses GUID terminology in documentation and developer workflows.
  • NEWID() is the common random GUID generator.
  • NEWSEQUENTIALID() improves locality but is not equivalent to GUID v7.
  • If you truly need RFC-compliant GUID v7, generate it in the application layer and store it in uniqueidentifier.

Practical notes

  • For random identifiers, GUID v4 remains the closest conceptual match.
  • For ordered inserts, SQL Server-specific sequential GUIDs may still be more practical than random GUIDs.
  • Read database performance guidance before choosing clustered keys.

Frequently Asked Questions

In practical SQL Server usage, NEWID behaves like the usual random GUID choice, but SQL Server documentation does not label it as RFC UUID v4 in everyday APIs.

No. SQL Server has sequential GUID features, but they are not native GUID v7 implementations.

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.

Learn more

These articles expand on related concepts, formats and practical considerations.

By using this site, you agree to our Privacy Policy and Terms of Service. You are not permitted to use the GUIDs (also known as UUIDs) generated by this site or use any other content, services and information available if you do not agree to these terms.
Disclaimer: All information is provided for general educational and technical reference only. While we aim to keep the content accurate, current and aligned with published standards, no guarantees are made regarding completeness, correctness or suitability for any specific use case.
GUID specifications, best practices, security guidance, database behavior and ecosystem conventions (including cloud platforms and identifier formats) may change over time or differ by implementation. Examples, recommendations and comparisons are illustrative and may not apply universally.
This content should not be considered legal, security, compliance or architectural advice. Before making critical design, security or production decisions, always consult the latest official standards and vendor-specific documentation.
Always evaluate behavior in your own environment.
Standards Compliance: The GUIDs generated by this site conform to RFC 4122 and RFC 9562 specifications whenever possible, using cryptographically secure random number generation.