DECLARE @a VARBINARY(10) SET @a=0xB4F3 SELECT CAST(@a AS VARCHAR(10))
+1这个是我的,繁琐了~
declare @int10 int declare @str16 varchar(10) declare @i int declare @t int declare @as varchar(10) declare @s1 int declare @s2 int ---->@as 自己设置16进制编码 set @as='B4F3' set @t=1 while @t<3 begin if @t=1 set @str16=left(@as,2) else set @str16=right(@as,2) set @int10=0 set @i=1 while @i<=len(@str16) begin set @int10=@int10+ convert(int, (case when substring(@str16,@i,1)<='9' then substring(@str16,@i,1) when substring(@str16,@i,1)<='A' then '10' when substring(@str16,@i,1)<='B' then '11' when substring(@str16,@i,1)<='C' then '12' when substring(@str16,@i,1)<='D' then '13' when substring(@str16,@i,1)<='E' then '14' when substring(@str16,@i,1)<='F' then '15' end )) * power(16,len(@str16)-@i) set @i=@i+1 end if @t=1 set @s1=@int10 else set @s2=@int10 set @t=@t+1 --print(@int10) endselect char(@s1)+char(@s2) /* -->测试结果---- 大
SELECT CONVERT(varchar, 0xB4F3)
SET @a=0xB4F3
SELECT CAST(@a AS VARCHAR(10))
declare @int10 int
declare @str16 varchar(10)
declare @i int
declare @t int
declare @as varchar(10)
declare @s1 int
declare @s2 int
---->@as 自己设置16进制编码
set @as='B4F3'
set @t=1
while @t<3
begin
if @t=1 set @str16=left(@as,2)
else set @str16=right(@as,2)
set @int10=0
set @i=1
while @i<=len(@str16)
begin
set @int10=@int10+
convert(int,
(case
when substring(@str16,@i,1)<='9' then substring(@str16,@i,1)
when substring(@str16,@i,1)<='A' then '10'
when substring(@str16,@i,1)<='B' then '11'
when substring(@str16,@i,1)<='C' then '12'
when substring(@str16,@i,1)<='D' then '13'
when substring(@str16,@i,1)<='E' then '14'
when substring(@str16,@i,1)<='F' then '15' end )) * power(16,len(@str16)-@i)
set @i=@i+1
end
if @t=1 set @s1=@int10
else set @s2=@int10
set @t=@t+1
--print(@int10)
endselect char(@s1)+char(@s2)
/*
-->测试结果----
大