Thoughts on Using GUID as a Primary Key Instead of int in MS SQL Server

Recently we were in a situation where we need to merge data from our offline version of application with online database.
We planned to use uniqueidentifier as data type for ID columns instead of int (auto identity).

But when we looked at reviews a lot of people were against this idea, they said if we use uniqueidentifier column as primary key (and clustered index) then there will be lot of fragmentation in our database, also the extra size of key.

Some people suggested that use the int type (auto identity) as primary key and add another column of uniqueidentifier type for this purpose. We decided to go with this idea and added a uniqueidentifier column in each table.

We don’t see any issue in this design right now and hopefully it will work for long term.

Share it