SQL Server中实现varbinary与varchar类型之间的数据转换(二)
when @getchar='e' then 14
when @getchar='f' then 15
else convert(int,@getchar) end;
set @tempint=@getint*power(16,datalength(@tempchar)-@n)
set @totalint = @totalint + @tempint
set @n=@n+1
end
set @re=convert(varbinary(1),@totalint) + @re;
set @runNum=@runNum-1;
end
end
return @re
end
GO
测试示例:
select dbo.hexstr2varbin('ffffff2353f5feefaffae1fff1ffbaf1faffa33333333ff3aaafffffffaaff')