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 following statement updates the table mytab and sets 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.
UPDATE mytab 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.
The NEWID function is supported only in the following positions:
SELECT list of a top level query block
SET clause of an UPDATE statement
VALUES clause of INSERT...VALUES
You cannot use the NEWID function as a column default for a Sybase IQ table.
UNIQUEIDENTIFIER in “Binary data types”
UNIQUEIDENTIFIERSTR in Character data types