sqlserver int to hex
create function [dbo].[inttohex](@i int) returns varchar(15) begin --declare @int --set @i=11259375 declare @r varchar(10) set @r='' while @i/16>0 begin set @r= ( case when (@i%16)<=9 then convert(varchar(1),@i%16) when (@i%16)<=10 then 'A' when (@i%16)<=11 then 'B' when (@i%16)<=12 then 'C' when (@i%16)<=13 then 'D' when (@i%16)<=14 then 'E' when (@i%16)<=15 then 'F' end )+@r --select @r,@i set @i = @i/16 end --select @r,@i if @i>0 set @r = (case when(@i%16)<=9 then convert(varchar(1),@i%16) when (@i%16)<=10 then 'A' when (@i%16)<=11 then 'B' when (@i%16)<=12 then 'C' when (@i%16)<=13 then 'D' when (@i%16)<=14 then 'E' when (@i%16)<=15 then 'F' end)+@r --select @r return @r end
xixi
浙公网安备 33010602011771号