Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2009
    Posts
    12

    Unanswered: How to Generate Customized Integer-Based GUID

    Hi,

    Anybody ever created customized interger-base GUID and used it as keys for multiple tables? How did you return the GUID to client application after insert?

    Thanks,
    Tina
    Last edited by Springwater; 08-27-09 at 11:00.

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Nope. How come it has to be an integer GUID?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Aug 2009
    Posts
    12
    That is a requirement and we can not use out-of-box uniqueidentifier since we want a better readability.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Many people consider the unreadability of GUIDs one of their advantages since it prevents people even considering reading them!

    You have a big problem of serialisation (as you always would for generating your own surrogate key), but this is compounded massively by wanting something unique across tables.

    I think I would consider a sub-type, super-type model with an identity column in the super-type table and use that for your user friendly integer GUID. The requirements aren't clear enough to give a better answer at this stage.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Identity anyone?
    Code:
    DECLARE @t table (
       id int identity(1,1)
     , a char(1)
    )
    
    INSERT INTO @t (a) VALUES ('a')
    INSERT INTO @t (a) VALUES ('b')
    INSERT INTO @t (a) VALUES ('c')
    
    SELECT id
         , a
    FROM  @t
    EDIT: just noticed the "multiple tables" bit - ignore this post.
    George
    Home | Blog

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Quote Originally Posted by Springwater
    That is a requirement and we can not use out-of-box uniqueidentifier since we want a better readability.
    Somebody is clueless. Not saying who, not saying its you, but somebody...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •