TheRealMagic TheRealMagic - 3 months ago 17
SQL Question

What is the statement to create a primary key in SQL like "3585c5d240dd4132bab35ab969137f3f"

I'm working with SQL Server Management Studio. I want to create a primary key like "3585c5d240dd4132bab35ab969137f3f" with a statement from SQL but I don't know the statement to create a primary key.
Can someone tell me what the statement is, to create a primary key like this?

Answer

This value seems to be a Universally Unique IDentifier, or UUID for short.

In MS SQL Server, you can use the newid() function to generate such an identifier. E.g.:

SELECT NEWID()
Comments