Translate numbers stored in char field to readable text

  • I have a database without any real diagrams/explanations.  There is a definition table hold a description field that has numeric stored as fixed char(105) field that I'm hoping someone will recognize and be able to help me translate to readable text.  e.g.  table 1, DefID (int)=8, Description (char(105))=78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000   Does anyone know how to translate/parse this so that it's readable in English?
    Thx.

  • Janet Barnett - Friday, October 5, 2018 10:23 AM

    I have a database without any real diagrams/explanations.  There is a definition table hold a description field that has numeric stored as fixed char(105) field that I'm hoping someone will recognize and be able to help me translate to readable text.  e.g.  table 1, DefID (int)=8, Description (char(105))=78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000   Does anyone know how to translate/parse this so that it's readable in English?
    Thx.

    Try this, maybe it means something to you?

    SELECT
     CONVERT(
         VARCHAR(MAX)
        , CONVERT(VARBINARY(MAX), '78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000', 2)
        )

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • That's so awesome!  Did the trick.  THANK YOU!

  • Phil Parkin - Friday, October 5, 2018 11:05 AM

    Janet Barnett - Friday, October 5, 2018 10:23 AM

    I have a database without any real diagrams/explanations.  There is a definition table hold a description field that has numeric stored as fixed char(105) field that I'm hoping someone will recognize and be able to help me translate to readable text.  e.g.  table 1, DefID (int)=8, Description (char(105))=78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000   Does anyone know how to translate/parse this so that it's readable in English?
    Thx.

    Try this, maybe it means something to you?

    SELECT
     CONVERT(
         VARCHAR(MAX)
        , CONVERT(VARBINARY(MAX), '78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000', 2)
        )

    Be careful here, there are some 0x00 in there, will be translated as a string terminator, which cause the subsequent data to be ignored!
    😎 

    Here is a workaround
    SELECT
    CONVERT(
      VARCHAR(MAX)
      , CONVERT(VARBINARY(MAX), REPLACE('78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000','00','32'), 2)
      )

  • Eirikur Eiriksson - Friday, October 5, 2018 11:20 AM

    Be careful here, there are some 0x00 in there, will be translated as a string terminator, which cause the subsequent data to be ignored!
    😎 

    Here is a workaround
    SELECT
    CONVERT(
      VARCHAR(MAX)
      , CONVERT(VARBINARY(MAX), REPLACE('78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000','00','32'), 2)
      )

    Nice work, well spotted.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Phil Parkin - Friday, October 5, 2018 11:29 AM

    Eirikur Eiriksson - Friday, October 5, 2018 11:20 AM

    Be careful here, there are some 0x00 in there, will be translated as a string terminator, which cause the subsequent data to be ignored!
    😎 

    Here is a workaround
    SELECT
    CONVERT(
      VARCHAR(MAX)
      , CONVERT(VARBINARY(MAX), REPLACE('78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000','00','32'), 2)
      )

    Nice work, well spotted.

    Heh, must have been a bit tired, used decimal (32) instead of the hex(20), here is the correct query
    😎


    CONVERT(
      VARCHAR(MAX)
      , CONVERT(VARBINARY(MAX), REPLACE('78424120202020202020204D69737365642041707074730020202020202020202020202020202020313034383537363000202000','00','20'), 2)
      )

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

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