1. Function: 16进制转字符串

 Create FUNCTION [dbo].[f_hextostr] (@hexstring VARCHAR(max))
 RETURNS VARCHAR(max)
 
 AS
 
 begin
 declare @char1 char(1), @char2 char(1), @strlen int, @currpos int, @result varchar(max)
  set @strlen=len(@hexstring)
  set @currpos=1
  set @result=''
  while @currpos<@strlen
   begin
    set @char1=substring(@hexstring,@currpos,1)
    set @char2=substring(@hexstring,@currpos+1,1)
    if (@char1 between '0' and '9' or @char1 between 'A' and 'F')
     and (@char2 between '0' and '9' or @char2 between 'A' and 'F')
     set @result=@result+
      char((ascii(@char1)-case when @char1 between '0' and '9' then 48 else 55 end)*16+
      ascii(@char2)-case when @char2 between '0' and '9' then 48 else 55 end)
    set @currpos = @currpos+2
   end
  return @result
 end
View Code

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2021-05-20
  • 2022-01-08
  • 2021-07-04
  • 2021-08-16
  • 2021-07-02
猜你喜欢
  • 2021-08-22
  • 2021-08-09
  • 2021-09-17
  • 2021-11-19
  • 2021-11-30
  • 2021-06-21
  • 2021-09-18
相关资源
相似解决方案