Click here to Skip to main content
15,944,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Friends,

I have used NewID() in SQL which give me the Unique ID.
But I want to know on what bases it is generated.


A Guid is 32 hex digits grouped into chunks of 8-4-4-4-12. Number of unique Guids is 2^128. Thats a lot..
Guids are created in different ways. The most used Guid is a version 4 Guid based on Time, MAC-address and Random data. (the first number of 3rd chunk is the version number)

Since it's using both Mac-address and Time, the only way to create a duplicate Guid is to adjust them clock on your server back in time and try to regenerate a duplicate. You'll never manage to create duplicates, but i theory you can.
Share this answer
Arunprasath Natarajan 16-Aug-12 0:29am    
Tan Q
NewID generates a Globally Unique IDentifier, or GUID. This is a 128 bit number which means that there is less chance of getting a duplicate value that there is of you winning the lottery.

This week.

And next week.

And every single week from now to the end of your life.

The generated value is not truly unique, but the odds are so high that they can be treated as unique values for all practical purposes.
Share this answer
Arunprasath Natarajan 15-Aug-12 7:51am    
Tan q, Can you give me the logic of its generation...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900