Wednesday, November 25, 2015

Uniqueidentifier in SQL Servers

Uniqueidentifiers are also called GUIDs(Globally Unique Identifier) which are unique and different from any other. It was introduced in SQL Server 7.0. The GUID is obtained by the function call NewID(). The unique identifier data type is stored in the computer as a 16-byte (128 bits) binary value. The formatted GUID using Hexadecimal is usually shown as a group separated by hyphens:
4bytes-2bytes-2bytes-2bytes-6bytes
Here is how the uniqueidentifier obtained by calling the NewID() function.
---
Declare @myid uniqueidentifier
set @myid=NEWID()

---
A uniqueidentifier is obtained every time this function is called as shown here:



While it is great for security, it takes up too much space (think of millions of rows with a uniqueidentifier data type column).

More about uniqueidentifier in SQL Servers here.

No comments:

Post a Comment

I am not paying this invoice. I am disregarding it, becuase....

 I am not paying this invoice because MICROSOFT has not provided me with a satisfactory way to access my account since June of this year des...