UUIDTOSTR Function [String]

Converts a unique identifier value (UUID, also known as GUID) to a string value.

Syntax

UUIDTOSTRuuid-expression )

Parameters

Parameters

Parameter

Description

uuid-expression

A unique identifier value.

Returns

VARCHAR

Example

To convert a unique identifier value into a readable format, execute a query similar to:

CREATE TABLE T3 (
pk uniqueidentifier primary key,c1 int);
INSERT INTO T3 (pk, c1) 
values (0x12345678123456789012123456789012, 1)
SELECT UUIDTOSTR(pk) FROM T3

Usage

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 unique identifier, NULL is returned.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Related concepts
Binary Data Types
Related reference
Binary Data Types
NEWID Function [Miscellaneous]
STRTOUUID Function [String]
Character Data Types