GUID not unique

  • If you were going to convert a guid to a varchar would the conversion not be a varchar(36)?

  • wierd, i've always used a varchar(40) for GUIDS/NEWIDs, but when i run this code, you are right, they are always 36 characters:

    declare @newid varchar(200)

    select @newid = newid()

    select len(@newid) as lengthofGUID,@newid as GUID

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • timscronin (1/28/2009)


    If you were going to convert a guid to a varchar would the conversion not be a varchar(36)?

    Probably not... since all GUID's are 36 characters, why not save the tiny bit of overhead and use CHAR(36)?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply