Article ID: 104829
Article Last Modified on 2/22/2005
create procedure sp_hexadecimal
@binvalue varbinary(255)
as
declare @charvalue varchar(255)
declare @i int
declare @length int
declare @hexstring char(16)
select @charvalue = '0x'
select @i = 1
select @length = datalength(@binvalue)
select @hexstring = "0123456789abcdef"
while (@i <= @length)
begin
declare @tempint int
declare @firstint int
declare @secondint int
select @tempint = convert(int, substring(@binvalue,@i,1))
select @firstint = floor(@tempint/16)
select @secondint = @tempint - (@firstint*16)
select @charvalue = @charvalue +
substring(@hexstring, @firstint+1, 1) +
substring(@hexstring, @secondint+1, 1)
select @i = @i + 1
end
select 'sp_hexadecimal'=@charvalue
declare @bin varbinary(255)
select @bin = @@dbts
execute sp_hexadecimal @bin
select 'isql' = @bin
go
sp_hexadecimal
------------------------------------------------------------------
0x01000000a60b0000
(1 row affected)
isql
------------------------------------------------------------------
0x01000000a60b0000
(1 row affected)
Additional query words: Windows NT
Keywords: kbinfo kbother KB104829