Posted on

There are a few use cases for using a GUID as a primary key on a table. If you fall into one of those categories, make sure you are optimizing storage by properly defining an incrementing clustered index.

You can solve some problems by using NEWSEQUENTIALID() to generate your key, but that actually can make things worse. For example, this forces you to use a database-generated GUID, which means your app won’t know the ID until the insert is done. It also means you can’t migrate your records from one database to another without paging issues.

Here’s a good read on the subject: GUIDs as PRIMARY KEYs and/or the clustering key.

View code on GitHub

Leave a Reply

Your email address will not be published. Required fields are marked *