AW: AW: [AccessD] Convert a byte value to a hex-string

Michael Brosdorf michael.broesdorf at web.de
Tue Jul 20 04:47:24 CDT 2004


Hi Gustav,

I simply replaced CREATE PROCEDURE with CREATE FUNCTION and set the return
value - so it is not really _my_ work ;-)
Ah, and removed the leading '0x'...

Here is the result:

CREATE FUNCTION dbo.myUDF_Binary2HexString (@binvalue varbinary(255))

RETURNS varchar(255) AS

begin
  declare @hexvalue varchar(255)
         , at charvalue varchar(255)
         , at i int
         , at length int
         , at hexstring char(16)
  select @charvalue = ''
        , at i=1
        , at length=datalength(@binvalue)
        , at hexstring = '0123456789abcdef'
  WHILE (@i<=@length)
    begin
      declare @tempint int
             , at firstint int
             , at secondint int
      select @tempint=CONVERT(int, SUBSTRING(@binvalue, at i,1))
      select @firstint=FLOOR(@tempint/16)
      select @secondint=@tempint - (@firstint*16)
      select @charvalue=@charvalue
            +SUBSTRING(@hexstring, at firstint+1,1)
            +SUBSTRING(@hexstring, @secondint+1, 1)
     select @i=@i+1
    end
return @charvalue
end



-----Ursprungliche Nachricht-----
Von: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com]Im Auftrag von Gustav Brock
Gesendet: Dienstag, 20. Juli 2004 10:33
An: Access Developers discussion and problem solving
Betreff: Re: AW: [AccessD] Convert a byte value to a hex-string


Hi Michael

So why not share this great work of yours?

/gustav


> Brett pointed me to thie KB-article:
> http://support.microsoft.com/default.aspx?scid=kb;en-us;104829

> I implemented this approach as a user-defined-function and it works great!

--
_______________________________________________
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list