SQL Server – NEWID () vs. NEWSEQUENTIALID ()
NEWID ()
NEWID () creates a unique value of type uniqueidentifier.
- NEWID () can be referenced in the queries.
Example:
NEWSEQUENTIALID ()
NEWSEQUENTIALID () creates a GUID that is greater than any GUID previously generated by this function on a specified computer since Windows was started. After restarting Windows, the GUID can start again from a lower range, but is still globally unique.
- NEWSEQUENTIALID () cannot be referenced in queries.
Example:
Example:
Using table
Imp Note:
- Each GUID generated by using NEWSEQUENTIALID () is unique on that computer. GUIDs generated by using NEWSEQUENTIALID () are unique across multiple computers only if the source computer has a network card.
- When a GUID column is used as a row identifier, using NEWSEQUENTIALID can be faster than using the NEWID function.