Get Random Unique Value (GUID) in SQL Server?

Updated on     Kisan Patel

To get a random unique value (Guid – Globally Unique Identifier) in SQL Server, we use NEWID function.
SELECT NEWID()
sql-server-new-id
You can also create a unique value of type uniqueidentifier.

DECLARE @myid uniqueidentifier
SET @myID = NEWID()
PRINT 'Value of @myID is: '+ CONVERT(varchar(255), @myID)

 

sql-server-uniqueidentifier


SQL Server

Leave a Reply