declare @hexstring varchar(max); set @hexstring = '0xabcedf012439'; select CONVERT(varbinary(max), @hexstring, 1); set @hexstring = 'abcedf012439'; select CONVERT(varbinary(max), @hexstring, 2);