Click to Rate and Give Feedback
MSDN
MSDN Library
SQL Server
SQL Server 2008
Database Engine
Technical Reference
 NEWSEQUENTIALID() (Transact-SQL)
Other versions are also available for the following:
SQL Server 2008 Books Online
NEWSEQUENTIALID() (Transact-SQL)

Creates a GUID that is greater than any GUID previously generated by this function on a specified computer.

Important:
If privacy is a concern, do not use this function. It is possible to guess the value of the next generated GUID and, therefore, access data associated with that GUID.

Topic link icon Transact-SQL Syntax Conventions

NEWSEQUENTIALID ( )

uniqueidentifier

NEWSEQUENTIALID() can only be used with DEFAULT constraints on table columns of type uniqueidentifier. For example:

CREATE TABLE myTable (ColumnA uniqueidentifier DEFAULT NEWSEQUENTIALID()) 

When NEWSEQUENTIALID() is used in DEFAULT expressions, it cannot be combined with other scalar operators. For example, you cannot execute the following:

CREATE TABLE myTable (ColumnA uniqueidentifier DEFAULT dbo.myfunction(NEWSEQUENTIALID())) 

In the previous example, myfunction() is a scalar user-defined scalar function that accepts and returns a uniqueidentifier value.

NEWSEQUENTIALID() cannot be referenced in queries.

You can use NEWSEQUENTIALID() to generate GUIDs to reduce page contention at the leaf level of indexes.

Each GUID generated by using NEWSEQUENTIALID() is unique on that computer. GUIDs generated by using NEWSEQUENTIALID() are unique across multiple computers only if the source computer has a network card. For more information about GUIDs, see Using uniqueidentifier Data.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker