Link to home
Start Free TrialLog in
Avatar of nmretd
nmretd

asked on

How long is a guid

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 ?
Avatar of mrichmon
mrichmon

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.
ASKER CERTIFIED SOLUTION
Avatar of SmithJW
SmithJW

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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}