Generate New (uniqueidentifier) in SQL Server

If you want to generate a new uniqueidentifier in SQL you can simply use the NEWID() function

       -- Example 1
       SELECT NEWID()

       -- Example 2       
       DECLARE @EmployeeID uniqueidentifier
       SET @EmployeeID = NEWID()

       -- Example 3
       INSERT INTO Employees(EmployeeID, Name)
       VALUES (NEWID(), 'msm2020')

Comments

Popular posts from this blog

OCR text detection with google APIs C#

The specified version string contains wildcards, which are not compatible with determinism.

How to set dynamically height/width of an external image in rdlc report?