ASA SQL Reference
SQL Functions
Alphabetical list of functions
Converts a unique identifier value (UUID, also known as GUID) to a string value.
UUIDTOSTR( uuid-expression )
uuid-expression A unique identifier value.
Converts a unique identifier to a string value in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, where x is a hexadecimal digit. If the binary value is not a valid uniqueidentifier, NULL is returned.
This function is useful if you want to view a UUID value.
SQL/92 Vendor extension.
SQL/99 Vendor extension.
Sybase Not supported by Adaptive Server Enterprise.
NEWID function [Miscellaneous]
The following statement creates a table mytab with two columns. Column pk has a unique identifier data type, and column c1 has an integer data type. It then inserts two rows with the values 1 and 2 respectively into column c1.
CREATE TABLE mytab( pk uniqueidentifier primary key default newid(), c1 int ) INSERT INTO mytab( c1 ) values ( 1 ) INSERT INTO mytab( c1 ) values ( 2 )
Executing the following SELECT statement returns all of the data in the newly created table.
SELECT * FROM mytab
You will see a two-column, two-row table. The value displayed for column pk will be binary values.
To convert the unique identifier values into a readable format, execute the following command:
SELECT uuidtostr(pk),c1 FROM mytab