Generates a UUID (Universally Unique Identifier) value.
The returned UUID value is a binary. A UUID is the same as a GUID (Globally Unique Identifier).
UNIQUEIDENTIFIER
The following statement creates the table t1 and then updates the table, setting the value of the column uid_col to a unique identifier generated by the NEWID function, if the current value of the column is NULL.
CREATE TABLE t1 (uid_col int); UPDATE t1 SET uid_col = NEWID() WHERE uid_col IS NULL
If you execute the following statement,
SELECT NEWID()
the unique identifier is returned as a BINARY(16). For example, the value might be 0xd3749fe09cf446e399913bc6434f1f08. You can convert this string into a readable format using the UUIDTOSTR() function.
The NEWID() function generates a unique identifier value.
UUIDs can be used to uniquely identify objects in a database. The values are generated such that a value produced on one computer does not match that produced on another, hence they can also be used as keys in replication and synchronization environments.
SELECT list of a top level query block
SET clause of an UPDATE statement
VALUES clause of INSERT...VALUES
You can use a value generated by the NEWID function as a column default value in a Sybase IQ table.