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 ?
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
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.
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();
System.Guid guid = System.Guid.NewGuid();
Split SmithJW {16271757} & mrichmon {16271838} & graye{16271874} & devsolns {16272338}