Thursday, October 25, 2012

Generate GUID in SQL SERVER

Posted by Rahul Kharde at 9:26 AM

Use NEWID() function to create unique guid.

SELECT NEWID()

Example

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

CREATE TABLE Employees
(
      EID   UNIQUEIDENTIFIER,
      ENAME VARCHAR(100)
)

INSERT INTO Employees VALUES(NEWID(),'ABC')

INSERT INTO Employees VALUES(NEWID(),'PQR')

SELECT * FROM Employees





If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top