Customer ID from GUID

  • Ive been tasked with pulling back customer info for a customer report. Problem is whoever designed the customer table decided it was only necessary to use a GUID as the id on the table.

    without doing anything fancy like building a mapping table or altering the table can i generate an ID that i can include on my customer report that will tie back to the GUID? i can only really rely on the GUID field.

    Thanks

  • So, you have data that looks like this:

    C828EB51-7A7B-40B1-A0CE-CF37559DC3F9

    And you want to display this:

    1168198242

    Correct?

    I guess my question is why do you need to display this data at all? Will the name of the customer suffice?

    This may work for you.

    DECLARE @GUID uniqueidentifier = newid()

    PRINT @GUID

    SELECT CHECKSUM(@guid)

    This may return negative numbers, so take that into consideration.

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • GUID is an ID! So if you say that you need another ID please share your idea of what that ID should look like.


    Alex Suprun

  • thanks,

    yes having a guid like C828EB51-7A7B-40B1-A0CE-CF37559DC3F9 as a customer ref on a report is obviously overkill, so was looking for a shortened unique ref that could be generated from this like 2654231 etc.

  • In short, no you can't. You really need some fancy things like those you mentioned above to tie new short id back to original GUID.

Viewing 5 posts - 1 through 4 (of 4 total)

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