uniqueidentifier

Transact-SQL Reference

Transact-SQL Reference

uniqueidentifier

A globally unique identifier (GUID).

Remarks

A column or local variable of uniqueidentifier data type can be initialized to a value in two ways:

  • Using the NEWID function.

  • Converting from a string constant in the following form (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx, in which each x is a hexadecimal digit in the range 0-9 or a-f). For example, 6F9619FF-8B86-D011-B42D-00C04FC964FF is a valid uniqueidentifier value.

Comparison operators can be used with uniqueidentifier values. However, ordering is not implemented by comparing the bit patterns of the two values. The only operations that are allowed against a uniqueidentifier value are comparisons (=, <>, <, >, <=, >=) and checking for NULL (IS NULL and IS NOT NULL). No other arithmetic operators are allowed. All column constraints and properties except IDENTITY are allowed on the uniqueidentifier data type.

See Also

ALTER TABLE

CAST and CONVERT

CREATE TABLE

Data Type Conversion

Data Types

DECLARE @local_variable

DELETE

INSERT

NEWID

Replication Overview

SET @local_variable

UPDATE