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
Post a Comment