uniqueidentifier In MS SQL

uniqueidentifier In MS SQL

 

Example

create table t1

(

  id uniqueidentifier DEFAULT NEWSEQUENTIALID(),

  name varchar(max)

);

 

insert into t1(name) values('Vidya Gyan 1');

insert into t1(name) values('Vidya Gyan 2');

insert into t1(name) values('Vidya Gyan 3');

select * From t1;

 

 

Microsoft Says

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 can be performed against a uniqueidentifier value are comparisons (=, <>, <, >, <=, >=) and checking for NULL (IS NULL and IS NOT NULL). No other arithmetic operators can be used. All column constraints and properties, except IDENTITY, can be used on the uniqueidentifier data type. and same as Guid id=Guid.NewGuid();