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

Do you know what you installed while custom installing SQL Server 2022?

 When you install any software in Windows OS, the key information gets into the Registry and some of which you can look up in the control pa...