Convert Binary to Ascii

Hi Guys,

I've got a question about how to convert binary to ascii.
I'm using sql server 2k and reporting services.
In the database i have a field with binary code in it and i want to convert it to plain text (ascii).

Can anybody help me with a script,code, function, whatever....

Many thanx in advance.

Gabs



Answer this question

Convert Binary to Ascii

  • Yoni Gibbs

    For the source of the field, replace the field name with a T-SQL statement. Use the CAST or CONVERT statements in T-SQL to take the field from binary to ascii.

    Buck



  • mneedham

    No problem. Within the field that is on your report, you can select the data source you want. That source can be a field from a table, view or stored procedure, text, numerics, whatever you want. In this case set the field to have a data source of a T-SQL statement. In that statement, perform a select of the field you're interested in, but apply the CONVERT() or CAST() functions to it. Like this:

    SELECT CAST(foo AS varchar(255)) FROM footable

    Try this in Query Analyzer (or Management Studio for SQL 2K5) to make sure you get what you want. Understand that if the binary is larger than varchar can handle, this won't work.



  • sonovo

    Tks a lot....

    This was a solution for a big problem....

    Tks

    Pedro



  • Ruprect8696

    Again, many thanx for the quick responce but when i used this statement, it returned an error.
    "Explicit conversion from data type image to varchar is not allowed"
    I've also tried, in stead of varchar, text, char, but none worked.
    It's driving me crazy man. I've tried so many solutions, but none of them worked.

    Greetz Gabs


  • Alan Hebert

    Tankx for the quick response, but i'm a noob in this kinda stuff, so could you explain this in lame terms.

    With many regards.

    Gabs


  • garmhappy

    He man,

    Thanx for all the help, I solved the problem.
    This was my solution:
    SELECT CONVERT(VARCHAR(8000),CONVERT(VARBINARY(8000),INHOUD)) AS INHOUD FROM OpdrahtDetail.

    Again, thanx for all the help.

    You're my savior man.

    Greetz Gabs


  • Convert Binary to Ascii