Wednesday, December 27, 2006

Create Your Own Sequential GUIDs (like NewSequentialID() in SQL 2005)

Scott BellwareA Class that Creates Sequential GUIDs

"My current project uses GUID primary keys in a SQL Server 2005 database.  The primary keys are created in the middle tier.  I want to use the equivalent of SQL Server 2005's NEWSEQUENTIALID() function to create GUIDs that are friendly to clustered indexes.

The NEWSEQUENTIALID() function uses the UuidCreateSequential function from the rpcrt4.dll library in the Windows API.

Here's a class that generates sequential GUIDs much in the same way that SQL Server 2005 does: 

..."

That could handy. I might even be able to use this in my existing VB6 app suite (where we're using SQL2k and guid's generated in the middle tier)... hum...

No comments: