ASA SQL Reference
SQL Functions
Alphabetical list of functions
Generates a UUID (Universally Unique Identifier) value. A UUID is the same as a GUID (Globally Unique Identifier).
NEWID( )
There are no parameters associated with NEWID().
The NEWID() function generates a unique identifier value. It can be used in a DEFAULT clause for a column.
UUIDs can be used to uniquely identify rows in a table. The values are generated such that a value produced on one computer will not match that produced on another. Hence they can also be used as keys in replication and synchronization environments.
NEWID is a non-deterministic function. Successive calls to NEWID may return different values. The query optimizer does not cache the results of the NEWID function.
For more information about non-deterministic functions, see Function caching.
SQL/92 Vendor extension.
SQL/99 Vendor extension.
Sybase Not supported by Adaptive Server Enterprise.
UNIQUEIDENTIFIER data type [Binary]
The following statement creates a table mytab with two columns. Column pk has a unique identifier data type, and assigns the newid() function as the default value. Column c1 has an integer data type.
CREATE TABLE mytab( pk uniqueidentifier primary key default newid(), c1 int )
If you execute the following statement,
SELECT newid()
the unique identifier is returned as a string. For example, the value might be 0xd3749fe09cf446e399913bc6434f1f08. You can convert this string into a readable format using the UUIDTOSTR() function.