This artcile explains the use of
ROWGUIDCOL in SQL Server.
Normally, when we use
UNIQUEIDENTIFIER column for PRIMARY KEY, we assign
NEWID() as the DEFAULT value for the column. SQL Server offers a more efficient and convenient way of achieving it.
Using the Code
For example, this is what we would normally use:
CREATE TABLE MyTable (ID UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID()...
Instead of the above, we can use the below definition:
CREATE TABLE MyTable (ID UNIQUEIDENTIFIER ROWGUIDCOL PRIMARY KEY DEFAULT NEWSEQUENTIALID()...
Points of Interest
We have the below advantages with this approach:
1) The UNIQUEIDENTIFIER along with
is far more efficient than normal
2) The Unique Ids generated with the second approach are sequential in nature, similar to
3) There can be max of one
for a table.
4) You can query the table for
SELECT ROWGUIDCOL FROM MyTable
Keep looking for updates, please rate this tip/trick.