0

Have a table that is populated by Entity Framework 3.1.1 code. The table contains a clustered index / primary key on ID which is defined as of type GUID with no default value. Is there a way in SQL to look at the row data and tell if the GUID values are a traditional random GUID vs a sequential GUID?

1
  • Probably not easily because that would be dependent on the specific algorithm that was used to generate the GUID. What is the end problem you're trying to solve by figuring that out?
    – J.D.
    Commented Feb 23, 2021 at 19:02

1 Answer 1

3

One easy way is to ORDER BY the UNIQUEIDENTIFIER and if they are sequential you'll see a pattern. EG

866381AE-0976-EB11-A396-5C80B6738BD2
876381AE-0976-EB11-A396-5C80B6738BD2
886381AE-0976-EB11-A396-5C80B6738BD2
896381AE-0976-EB11-A396-5C80B6738BD2
8A6381AE-0976-EB11-A396-5C80B6738BD2
8B6381AE-0976-EB11-A396-5C80B6738BD2
8C6381AE-0976-EB11-A396-5C80B6738BD2
8D6381AE-0976-EB11-A396-5C80B6738BD2
8E6381AE-0976-EB11-A396-5C80B6738BD2
8F6381AE-0976-EB11-A396-5C80B6738BD2
906381AE-0976-EB11-A396-5C80B6738BD2
916381AE-0976-EB11-A396-5C80B6738BD2
926381AE-0976-EB11-A396-5C80B6738BD2
936381AE-0976-EB11-A396-5C80B6738BD2
946381AE-0976-EB11-A396-5C80B6738BD2

But if the table doesn't have a DEFAULT of NEWSEQUENTIALID it's unlikely that they are sequential.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.