NEWSEQUENTIALID or GUID as a Primary Key

If you still don’t use GUIDs as a Primary Key for you tables, or if you do and use NEWID function, I have something to tell you.

Since MS SQL Server 2005 we could use NEWSEQUENTIALID function to create unique GUIDs.

It “creates a GUID that is greater than any GUID previously generated by this function on a specified computer since Windows was started” And it has the following advantages:

  1. It's faster than NEWID.
  2. It's optimize work with index pages.

I want to notice that GUIDs will be still unique accross multiple computers if the source computer has a network card.

So please don’t doubt it, GUIDs is a great option to be used as Primary Key.

I created a tiny script to play with NEWSEQUENTIALID.