Converting "image" to "nvarchar"?

Posted on 2006-05-05
Last Modified: 2008-03-17
Hi All,

I am trying to run a SELECT statement against a database table to be able to view (in human readable form) the contents of a field that is of type "image". Ideally I would like it in ntext or nvarchar, so that I can read it. Unfortunately, I have not been able to find a way of doing this. Would you have suggestions please?

Question by:takoraptor
    LVL 75

    Accepted Solution

    You can use the CAST to convert the image column to varbinary, binary or timestamp. from those you can convert to nvarchar. You can read only the binaryvalues stored in the image column
    SELECT CAST(CAST (urImageColumn AS varbinary) AS varchar(30)) FROM urTble
    LVL 75

    Expert Comment

    by:Anthony Perkins
    >>I am trying to run a SELECT statement against a database table to be able to view (in human readable form)<<
    Cannot be done with T-SQL alone.

    Author Comment

    Thanks! I had more than 30 chars in the field but that issue was trivially solved by doing a varbinary(8000) on the query you gave me... I guess that since varbinary does not accept more than 8000 chars, I cannot use this technique to see fields which have a bigger payload, but that is fine.

    Thanks to aneeshattingal and acperkins for their responses!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now