4

How to convert binary data to text?

I have column called File names in test table with image datatype so when i am selecting the data from test table its showing the data for file names column is binary data i.e ('0x433A5C55736535').

Regards Anji

Bogdan Sahlean
  • 19,233
  • 3
  • 42
  • 57
user3682923
  • 41
  • 1
  • 1
  • 3
  • Can you change the column type to something more appropriate? – CDahn Jun 14 '14 at 13:43
  • possible duplicate of [Convert integer to hex and hex to integer](http://stackoverflow.com/questions/703019/convert-integer-to-hex-and-hex-to-integer) – CDahn Jun 14 '14 at 13:51
  • Agree with @CDahn `image` datatype is a crazy choice for storing file names. It is for large binary data and deprecated. Not for fairly short text strings. – Martin Smith Jun 14 '14 at 19:30

2 Answers2

3

I can't beleive nobody answered this. If it's image data you won't get anything readable. but in case it is text data in a binary field, you can do this:

select cast(DataColumn as varchar(MAX)) as DataAsText from [TableWithData];
nivs1978
  • 1,126
  • 14
  • 20
  • 1
    I also sometimes get amazed at how SO community behaves. Can somebody explain why a simple, clear, and specific question like this wasn't answered for 7 years? – Aqeel Ashiq Mar 03 '22 at 07:46
-2

'0x433A5C55736535' is not binary data, binary data is composed only with 0 and 1.

I think you need to use the defined functions of your test table to get the data you want, if you are in MySQL it's "Select * from file names"