I need to take a string representation of a VARBINARY value and convert it back to the actual VARBINARY value, but how?
I want to take the results of the following query and convert it back to the VARBINARY value so I can decrypt it to it's original value?
CREATE TABLE Table1 (
FirstName varchar(32) NOT NULL,
LastName varchar(32) NOT NULL,
Social varbinary(128) NOT NULL)
OPEN SYMMETRIC KEY KEY_NAME
DECRYPTION BY CERTIFICATE CERT
INSERT INTO Table1(FirstName,LastName,Social)
VALUES ('John','Doe',ENCRYPTBYKEY(Key_Guid('KEY_NAME'),'123-45-6789'))
SELECT CONVERT(varchar(max), social,1) Social
FROM Table1
WHERE LastName='Doe'