Many of us already know the difference between NEWID() and NEWSEQUENTIALID() function. The GUID generated using NEWID() function is random in nature, which means, there is no guarantee that the the GUID generated is lower or higher than the previous GUID. And we all know that this was a burning issue becuase its not recommended to create clustered index on a column which has NEWID function as DEFAULT becuase it may cause huge fragementation, page splits, etc (obviously depending upon FILLFACTOR etc,). And not have that column as PRIMARY KEY for the same reasons. Well this is all too well know.
So, the solution is to use SQL Server NEWSEQUENTIALID function. Why? “Becuase it guarantees that the GUID generated will ‘always’ be higher/greater than the previous GUID”. Well, thats not ‘really’ true.
NEWSEQUENTIALID() function generates a GUID that is greater than any GUID previously generated on a specified computer since Windows was started. Yes, thats the catch here. If you restart Windows, which means, if you reboot, the GUID can start again from a lower range, but is still globally unique.
And there are many other caveats related to this. But this is a major one you should keep in your mind before using NEWSEQUENTIALID() function. So no guarantees here; you are going to reboot your box someday, aren’t you? 😉