declare @str varchar(20),@bin varbinary(20),@i int,@j int
set @str='0x1922D301'
set @bin=0x
set @i=1
while @i<len(@str)/2
begin
set @j=(case left(substring(@str,@i*2+1,2),1) when 'A' then 10
when 'B' then 11
when 'C' then 12
when 'D' then 13
when 'E' then 14
when 'F' then 15
when '1' then 1
when '2' then 2
when '3' then 3
when '4' then 4
when '5' then 5
when '6' then 6
when '7' then 7
when '8' then 8
when '9' then 9
when '0' then 0
END)*16
set @J=@J+ CAST(right(substring(@str,@i*2+1,2),1) AS INT)
SET @BIN=@BIN+CAST(@J AS BINARY(1))
set @i=@i+1
end
SELECT @BIN
/*
------------------------------------------
0x1922D301(所影响的行数为 1 行)
*/
set @str='0x1922D301'
set @bin=0x
set @i=1
while @i<len(@str)/2
begin
set @j=(case left(substring(@str,@i*2+1,2),1) when 'A' then 10
when 'B' then 11
when 'C' then 12
when 'D' then 13
when 'E' then 14
when 'F' then 15
when '1' then 1
when '2' then 2
when '3' then 3
when '4' then 4
when '5' then 5
when '6' then 6
when '7' then 7
when '8' then 8
when '9' then 9
when '0' then 0
END)*16
set @J=@J+ CAST(right(substring(@str,@i*2+1,2),1) AS INT)
SET @BIN=@BIN+CAST(@J AS BINARY(1))
set @i=@i+1
end
SELECT @BIN
/*
------------------------------------------
0x1922D301(所影响的行数为 1 行)
*/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货