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

C# Crop white space from around the image

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

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