Cover

Guids as Keys

March 21, 2007
No Comments.

Url: http://www.codinghorror.com/blog/archives/00081…

I was reading this codinghorror.com entry today and thought someone else was advocating Guids as keys when I saw mention of something I hadn’t seen before:

NEWSEQUENTIALID() Function in SQL Server 2005

This function (which is only valid in a columns’s DEFAULT constraint) will make GUIDs that are somewhat sequential which eliminates the biggest complaint of mine (fragmented PK Indexes).  It is SQL Server 2005 only, but its a cool feature.  To be clear this is how its used:

CREATE TABLE Employee 
            (EmployeeID uniqueidentifier DEFAULT NEWSEQUENTIALID())