GUID In SQL Server

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() 

1

For storing the GUID in the variable we make use of UNIQUEIDENTIFIER DATA TYPE.

declare @Guid UNIQUEIDENTIFIER
set @Guid=NEWID()
print @Guid

2


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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: