Generating a GUID

A GUID is a 128-bit integer (16 bytes) that can be used across all computers and networks wherever a unique identifier is required. Such an identifier has a very low probability of being duplicated. The term is usually referred to as GUID (Globally Unique Identifier) when working with Microsoft technologies. Otherwise, it is referred to as UUID (Universally Unique Identifier).

Here are multiple ways to generate a GUID:

Visual Studio

Run guidgen.exe. There are two ways to run guidgen:

  1. Open Visual Studio IDE, go to Tool menu, and select the Create Guid menu item. This option is available in VS 2008 but not in VS 2010. So use method 2 if you have VS 2010 installed.
  2. Open Visual Studio Command Prompt (from start menu) and enter the following command: guidgen.

Using any of the methods above, you get the following:


You can use any of the 4 formats available, but usually the Registry format (currently selected) is the mostly used one. To generate a new GUID, click New GUID. To copy the GUID to the clipboard, click Copy.


You can generate a Guid using any .Net language. Here is how you can do it with C#.

Guid myGuid = System.Guid.NewGuid();

SQL Server

A GUID is represented as type uniqueidentifier in T-SQL. It is generated as shown below.

SELECT newid()


If none of the above methods are available for you, you can get one generated online at


2 thoughts on “Generating a GUID

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s