This post sbout how to generate a random unique identifier in using sql query in SQL server
If you want to generate a new Guid (uniqueidentifier) in SQL server the you can simply use the NEWID() function.
Example
1 2 3 4 | SELECT NEWID() GO |
You can directly use this with INSERT statement to insert new row in table.
1 2 3 4 5 6 7 | -- Inserting data in Employees table. INSERT INTO Employees (EmployeeID, Name, Phone) VALUES (NEWID(), 'Jhon Craps', '99-99999') |