Guid is a 16-byte binary data type that is globally unique. GUID stands for Global Unique Identifier. Guid are globally unique between table, databases, servers.
Syntax
SELECT NEWID()
For storing the GUID in the variable we make use of UNIQUEIDENTIFIER DATA TYPE.
declare @Guid UNIQUEIDENTIFIER
set @Guid=NEWID()
print @Guid
declare @Guid UNIQUEIDENTIFIER
if(@Guid is null)
begin
print('Guid is null')
end
else
begin
print('Guid is not null')
end
set @Guid=NEWID()
select @Guid