Let say I have a varchar(100) call @hexString and I
SET @hexString ='0x47617279204a6f686e736f6e2032303230'
How do I cast this varchar to an actual hexidecimal 0x47617279204a6f686e736f6e2032303230(without the quotation mark)?
Let say I have a varchar(100) call @hexString and I
SET @hexString ='0x47617279204a6f686e736f6e2032303230'
How do I cast this varchar to an actual hexidecimal 0x47617279204a6f686e736f6e2032303230(without the quotation mark)?
Use CONVERT with a "style" value of 1:
DECLARE @HexString VARCHAR(100);
SET @HexString = '0x47617279204a6f686e736f6e2032303230';
SELECT CONVERT(VARBINARY(100), @HexString, 1);
The "style" value is an optional 3rd parameter to the CONVERT function.
That returns the following as a VARBINARY type, not a string:
0x47617279204A6F686E736F6E2032303230