Convert text string to hexadecimal or binary representation

Hi guys, the simple question is that I seemed to be at a dead end. I have something that works, but I get an empty result. I have a text string in a database column. for this question we can say that the text string is "jhonSmith". I would like to get a hexadecimal representation of this string. using a simple select query. I do not have access to create or call procedures in the database. this is the best that was able to come up with, but it returns empty. If I take the conversion function, it will work.

select distinct convert (varbinary, dim_employee.full_name) as Employee
from dim_employee
where 1=1

if I use varchar instead of varbinary, I get the data back, which makes me think that I am not doing it right. Can someone point me in the right direction. You are welcome!!!

+5
source share
1 answer

When I launched the next

select distinct convert (varbinary, 'Hogan') as Employee

I get the following

Employee
--------------------------------------------------------------
0x486F67616E

Maybe the problem is how you show the results?

+7
source

All Articles