varchar <-> varbinary 无损转换

--varchar -> varbinary
declare @hexstring varchar(64),@binstring varbinary(64)
set @hexstring = '0x01000200A09EFC30B04A69DE02000000000000000000000000000000000000';
SET @binstring = CONVERT(varbinary(64), @hexstring, 1);
SELECT @binstring
go

--varbinary -> varchar
declare @hexstring varchar(64),@binstring varbinary(64)
set @binstring = 0x01000200A09EFC30B04A69DE02000000000000000000000000000000000000
SET @hexstring = master.dbo.fn_varbintohexstr(@binstring)
SELECT @hexstring