Conversion of Hexadecimal Value To String - Most Urgent

  • Hi,

    Is there any UDF for conversion of Hexadecimal to a readable string?

    Like I have (0xB6FEFFFF00000000C4FFFFFF0000000000000000000000000000000000000000000000000000000000000000)

    I need to know what exactly it means, I don't know if my question makes sense, but any help would be highly appreciated.

    Thanks

    -Prasad

    Prasad Bhogadi
    www.inforaise.com

  • Not that I know of but you could write one like this

    CREATE  FUNCTION fn_hextovarchar

        (@input varchar(8000), @startoffset int = 1)

    RETURNS varchar(4000)

    AS

    BEGIN

      DECLARE @hex char(16),@output varchar(4000),@ptr int,@val int

      SET @hex = '0123456789ABCDEF'

      SET @output = ''

      SET @ptr = @startoffset

      WHILE @ptr < DATALENGTH(@input)

      BEGIN

        SET @val = ((CHARINDEX(SUBSTRING(@input,@ptr,1),@hex)-1) * 16) +

          (CHARINDEX(SUBSTRING(@input,@ptr+1,1),@hex)-1)

        SET @output = @output + CHAR(@val)

        SET @ptr = @ptr + 2

      END

      RETURN @output

    END

    Far away is close at hand in the images of elsewhere.
    Anon.

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

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