What is GUID and how to generate it in SQL Server?


GUID (Globally Unique Identifier) is a 128 bit unique number which is generated by Operating system automatically. This number is globally unique and can not be generated the same number in any other computer in the entire world. Identity key in a table generates unique number in that particular table. There is chance that we can find the same number in other tables. But GUID never be repeated in any other table or database or computer in the entire world.

               For example, If we consider a motor cycle, it will have a unique number registered to it. But this number might be repeated for some other product in some other country. But GUIDs are not like that. We can use GUIDs for anything in the world since no one can generate the same number which we have generated.





Real time usage of GUIDs:

  • Unique IDs for products in a shopping mall
  • Primary keys in databases
  • For generating Unique customer IDs of an organization
  • For generating files with unique names etc…

GUIDs in SQL Server are generated by using NEWID() function.



For more info: Click here

Happy Reading :)


Leave a Reply

Your email address will not be published. Required fields are marked *

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