We help IT Professionals succeed at work.

How long is a guid

nmretd asked
Medium Priority
Last Modified: 2011-10-03
I am generating a GUID and need to store this value in a db table. How long does the varchar datatype need to be to hold this value ?
Watch Question

Depends on the GUID, but is usually a 128 bit number.  Therefore you need at least 128 and then some GUIDs have dashes or spaces to break it up into more readable sections - hence that is shy I said it depends.  I would say that 150 should be plenty for all cases.

A GUID is 16-bytes (128-bits) written in hex

    3F2504E0 4F89 11D3 9A 0C 03 05 E8 2C 33 01

GUIDs are written using a four-byte word, 3 two-byte words, and a six-byte word, such as:


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
In most generators they are written as SMithJW showed which is generally 32 characters excluding spaces and dashes and brackets and other divider characters.  If your generator does that then you should only need about 50 characters for the max case.  But my first post covered worst case scenario.

However, I recommend testing your generator and then going off of that.  It should be consistent each time from teh same generator.

It is safe to remove any formatting characters i beleive, as they are in the same position for every GUID... at least that was my interpretation of them, i could be wrong...
If im right though, id seperate just the meaningful data to save space.
but yeah, as richmon says, test the generator and handle it from there.

Have you considered storing the GUID as a "GUID-type" in the database (rather than a string)?   Most databases natively support a GUID type

As your probably aware,

System.Guid guid = System.Guid.NewGuid();

Split SmithJW {16271757} & mrichmon {16271838} & graye{16271874} & devsolns {16272338}
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.