Posts Tagged ‘ uuid ’

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:

guidgen

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.

.Net

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()

Online

If none of the above methods are available for you, you can get one generated online at http://www.guidgenerator.com/.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: