tags:

views:

792

answers:

4

Hi I have a field which is varbinary. It has already been populated. Now how do i convert varbinary to varchar so that I can use the data in the field for some other purpose. I use a MySQL version 5.10

A: 

You can use cast operation:

select cast(column_name as varchar)
  from table_name
Pablo Santa Cruz
+1  A: 
cast(fieldname as varchar)
Sarfraz
It is throwing an error message when i use cast You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar) from table_name' at line 1
Saeros
how are you constructing your query, can you provide a prototype of it?
Sarfraz
I am not constructing it. It is a part of a third party app that i am using.
Saeros
A: 
ALTER TABLE table_name MODIFY column_name VARCHAR(128);
Yada
A: 

The MySQL syntax that worked for me in a similar scenario to this is:

select cast(binaryColumn as CHAR) from table_name
yanigisawa