Home > T-SQL > Unique Identifier and New ID – SQL Server

Unique Identifier and New ID – SQL Server


Unique Identifier  is an identifier that is considered to be a unique candidate among other identifiers in a list.

Uniqueidentifier is a 16 byte GUID (Global Unique Identifier) data type in SQL Server used to store GUID.

Example:

pic1

NEWID(): function is used to create a value of type uniqueidentifier. This value as 32 hexadecimal digits with groups separated by hyphens. The hexadecimal numbers are grouped as 8-4-4-4-12. You can also see that in the example given below.

Example:

pic2

We can create uniqueidentifier column in a table to store unique records. NEWID() function helps developer to create GUID easier and faster. So, we can consider using this data type in the table design.

There are other unique identifiers that are worth learning now.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

%d bloggers like this: