Both NEWID()
and NEWSEQUENTIALID()
give globally unique values of type uniqueidentifier
.
NEWID()
involves random activity, thus the next value is unpredictable, and it’s slower to execute.
NEWSEQUENTIALID()
doesn’t involve random activity, thus the next generated value can be predicted (not easily!) and executes faster than NEWID()
.
So, if you’re not concerned about the next value being predicted (for security reasons), you can use NEWSEQUENTIALID()
. If you’re concerned about predictability or you don’t mind the tiny performance penalty you can use NEWID()
.
However, in strict sense, there are still negligible chances that GUIDs generated by different machines have the same value. In practice, it’s considered as being impossible.
If you want further info, read this: Which method for generating GUIDs is best for ensuring the GUID is really unique?
Note NEWID()
complies RFC 4122. And the other function uses a Microsoft’s algorithm for generating the value.