Convert Binary Data to string in MsSQL

Hello,
I am running a query for MSSQL database to get some file content which is stored in Binary data format in the database.
I want to copy that file which is in the binary data format to a file in the text format.
How can I do this?
Regards,
Sravanthi

This is the expected result in the file that stores the data.
ResultElement     
WshOutputTest
Errors/Failures     
1 / -
Incident     
Error: some unexpected result     
function main()     
some additional info; eg. stacktrace
Incident     
Warning: some warning message     
function main()
some additional info; eg. stacktrace
But I am getting the following stored in my file:::
PK   FSH;
output.xmlíT»NÃ@œ‰8¥‚
*Æ)xH)      ‚R[ñÅ9AìȾðøy`nϖs1nBY>_vvfŸÊÏw„>±ÄÞ¡Q¢‚AWà§8ãWÉ1£=%š#ôÜá„^ü5BŒC ½+¬©iqËSSßñ-u&‚YŒù:»Ó™Ò²À#+9¯A©øDÔ*ù|¯y®E1fôìåN‘Ëëì»ü~¼ÕK{ ·0ßK֕2ÞbÞ*
*©\‰–fŸW<gRyJk¹Ñ'—Ã6?T¦ÍOÈÐÿ‹x[³cwñCÌRÛ0^ˆy¼éù}–.y»|ýF(ÚéЎ%f—ÓÕu]›“¿Ù„õ§’§WNdÿLíy)û–q÷”¨'Ìá•ßRnZ"·ªa•Ãž:ÎßóûÏl?‚ÍQbm=w™k¸‹ûÙî>[‡ôÿyŸ_PKÙõ¡¬N    PK    FSH;Ùõ¡¬N  * 
*output.xmlPK 8 †*
I tried getting the Binary Stream with UTF-8 encoding style and no encoding style too but it didnt work.
Thanks,
Sravanthi.

Similar Messages

  • Sample code converting binary data to image file

    Hi experts ,
    I need sample code to convert binary data (bytes) in to an image file.
    any help will be appreciated.
    Thanks and Regards,
    Naresh

    You need to show binary and decimal?  Or now just decimal?
    If binary and decimal, you can right click on your indicator and choose "Display Format...".  If you select the Advanced Editing Mode, you can make soft interesting display formats.  This includes showing the same value in mulitple ways in the indicator.  Try something like "%032b - %d" for the format string.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • How to convert BLOB data into string format.

    Hi,
    I have problem while converting blob data into string format.
    for example,
    Select dbms_lob.substr(c.shape.Get_wkb(),4000,1) from geotable c
    will get me the first 4000 byte of BLOB .
    When i using SQL as i did above,the max length is 4000, but i can get 32K using plsql as below:
    declare
    my_var CLOB;
    BEGIN
    for x in (Select X from T)
    loop
    my_var:=dbms_lob.substr(x.X,32767,1)
    end loop
    return my_var;
    I comfortably convert 32k BLOB field to string.
    My problem is how to convert blob to varchar having size more than 32K.
    Please help me to resolve this,
    Thanx in advance for the support,
    Nilesh

    Nilesh,
    . . . .The result of get_wkb() will not be human readable (all values are encoded into some binary format).
    SELECT utl_raw.cast_to_varchar2(tbl.geometry.get_wkt()) from FeatureTable tbl;
    -- resulting string:
        ☺AW(⌂özßHAA
    Å\(÷. . . .You may also want to have a look at { dbms_lob | http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_lob.htm#i1015792 } "The DBMS_LOB package provides subprograms to operate on BLOBs, CLOBs, NCLOBs, BFILEs, and temporary LOBs."
    Regards,
    Noel

  • Convert a date in String format to a Date

    Hi,
    How can I convert a date in String format to a Date object?
    I have tried:
    import java.text.*;
    import java.io.*;
    import java.util.Date;
    import java.util.Locale;
    import java.sql.*;
    public class casa {
    public static Connection con = null;
    public static Statement s = null;
    public static String sql = null;
    public static String mydate = "01.01.2001";
    /** Creates a new instance of casa */
    public casa() {
    public static void main(String[] args) throws SQLException{
    try {
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    Date date = shortFormat.parse(mydate);
    //Open Database
    con = getConnection();
    s = con.createStatement();
    sql = "select date1 from table1 where date1 <= '"+date+"'";
    ResultSet rs = s.executeQuery(sql);
    while(rs.next()){
    String aba = rs.getString("datum");
    System.out.println("New Datum = "+aba);
    } catch (Exception ex ) {
    ex.printStackTrace();
    closeConnection(s, con);
    //Connection
    private static Connection getConnection() {
    Connection con = null;
    String user ="aouzi";
    String passe ="aouzi";
    String url = "jdbc:db2:EjbTest";
    try {
    //Datenbanktreiber laden
    Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
    //Verbindung herstellen
    con = DriverManager.getConnection(url,user,passe);
    }catch(ClassNotFoundException e){
    } catch(SQLException e){}
    return con;
    //close Connection
    private static void closeConnection(Statement s, Connection con) {
    try {
    s.close();
    } catch (SQLException e) {}
    try {
    con.close();
    } catch (SQLException e) {}
    I'm getting the following errors:
    COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/NT] SQL0180N
    The syntax of the representation of a date/time of day value as character sequence is false. .SQLSTATE=22007

    I'm pretty sure it won't understand what date.toString() returns. If you know what format the database understands, you do it like this:
    SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yy"); // e.g. 18-Apr-02
    String datestring = sdf.parse(date);
    and use that instead of date in your sql string. Some databases understands it if you do
    "to_date('18-Apr-02')"
    so you could include that in your sql string as well..
    You could also try to make it a java.sql.Date and hope your jdbc driver knows how to convert it to a string that the database understands if you don't know the format:
    con = getConnection();
    PreparedStatement ps = con.prepareStatement("select date1 from table1 where date1 <= ?");
    ps.setDate(new java.sql.Date(date.getTime()));
    ResultSet rs = s.executeQuery(sql);

  • Converting binary data to cluster

    Hello,
    I have a problem converting binary data to a cluster. I have to create a VI that reads out some parameter from a device, which is connected via RS232. I get an array of 128 Byte from the device. The data has the following (C-)structure:
    struct PARAM
    char cVersion[64];
    float fDeviceID;
    float fChannels;
    float fSensor;
    float fTrigger;
    float fConst[5];
    char cReserved[28];
    How can I convert the binary array to a cluster? I created a cluster (see attachment), but I couldn't connect it with the "Type Cast" VI. Has anyone an idea how to solve this problem?
    Thanks, Martin
    Attachments:
    cluster.jpg ‏16 KB

    It is tedious to convert binary data to LabVIEW data when you have arrays. You have to typecast the data with clusters of the same fixed length as in the structure. Large clusters are easily created on the diagram using Array to Cluster primitive. See the attavhed picture.
    LabVIEW, C'est LabVIEW
    Attachments:
    conversion.gif ‏11 KB

  • Convert Binary Data into Pdf & send it as attachment in a mail in Workflow

    Hi,
    Scenario:
    The interactive form saved in WebDynpro Application is sent to R/3 in binary format. It has to be converted into pdf and sent it as an attachment in mail to the respective person in workflow.
    Kindly help on these issues :
    1. How to receive the binary data in R/3 sent by the WebDynpro Application ?
    To my knowledge we can receive the binary in XSTRING data type. Plz correct me if am wrong.
    2. How do i convert the received binary data into pdf ?
    Thanks,
    Bharath Kaushik

    Hi Bharath,
    I think you should try to write dat being sent to R/3 to spool first, as in R/3 there is FM <i>CONVERT_ABAPSPOOLJOB_2_PDF</i> , with the help of which you will be able to convert Binary data to PDF format.
    Pls find one of the threads related to this , and see if this is useful to you.
    Problem in CONVERT_ABAPSPOOLJOB_2_PDF.
    Hope this atleast helps to start off.
    Regds,
    Akshay Bhagwat
    PS: Some points would be nice if it helps:)

  • Convert the date of string to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.

    I need convert the date of string format 'MM/dd/yyyy' to datetime format 'MM/dd/yyyy' when the system date format is 'dd/MM/yyyy'.Since
    I need to search values based on date where my database datetime  is 'MM/dd/yyyy' format.

    In my opinion you should re-consider the assumption that the date picker returns a string. Maybe it is able to return a
    DateTime object directly instead of string. Then you will pass this value as a parameter of SQL query. This should work regardless of computer configuration.
    Otherwise, follow the previous string-based approaches.

  • How to convert DateField date to String ?

    Hi,
    I'm trying to convert DateField date to String.
    How can I do it because Data class does not have String converting
    methods...
    Thanks
    Krzysztof

    Hello,
    you can get an instance of Calendar and use it with the date as a long integer.
    public Calendar cal=Calendar.getInstance();
    myDate=dateField.getDate();
    cal.setTime(myDate);
    myDateString=cal.get(Calendar.DATE)+"."+cal.get(Calendar.MONTH)+"."+cal.get(Calendar.YEAR));
    Try it.
    Unfortunately I have found that the MIDlet get a day less when I use the same long integer that I got from an application on PC. I don't realy understand why but I' still searching.
    I hope it is usefull for you.
    ValeriuS

  • How to Convert Binary Data in Binary File

    hi,
    my telecom client puts a binary file which is asn.1 encoded with BER.
    how to handle binary data in java.
    how to convert binary to hexa to ascii format
    how to convert binary to octet to ascii format
    please help me in this.
    regards,
    s.mohamed asif

    You don't need to convert the data.
    Only you can do is print it in that formats, like it:
    public static String byteArrayToHex(byte[] b) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++)
             sb.append(Integer.toHexString(b&255) + " ");
    return sb.toString();
    take a look at this
    http://java.sun.com/docs/books/tutorial/essential/io/

  • Convert binary data (TIFF image) into XML - how ?

    Hi,
    I have the following requirement:
    1. A document is scanned and a TIFF image is saved in a directory
    2. The File adapter picks up the image file and sends into XI
    3. The binary data is converted into XML so a Web Service can be called (this web service will store the image in a database application)
    <b>The part I am struggling with is the convert of the incoming binary data into a XML format document which will allow the Web Service to be called.</b>
    Graphical mapping cannot be used therefore I am left with 3 options:
    1. XSLT mapping
    2. Java mapping
    3. ABAP mapping
    Can anyone suggest the best option to use in these circumstances and provide some sample snippet of code on how to do it.
    I am alright at XSLT mapping but this is beyond me and Java mapping is completely new to me as I have very limited Java knowledge.
    Thanks for your help
    Colin.

    Hi Colin
    Look for the below link
    https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b
    <b>***Reward point if helpfull</b>
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b">https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/10dd67dd-a42b-2a10-2785-91c40ee56c0b</a>

  • How to convert binary data to PDF and attach to the particular po

    our client wants to attach the pdf coming from portal as attachment to that particular PO. From portal the pdf will come in binary format. Find how will we convert that binary data back to pdf and attach to the PO in R/3?

    Hi,
    You can downlaod Binary data into PDF using GUI_DOWNLOAD...pass the binary data and the BINSIZE...
    santhosh

  • Convert Binary Data into Pdf & send it as attachment in a mail

    Hi Friends,
    Scenario :
    The interactive form saved in WebDynpro Application is sent to R/3 in binary format. It has to be converted into pdf and sent it as an attachment in mail to the respective person.
    Kindly help on these issues :
    1. How to receive the binary data in R/3 sent by the WebDynpro Application ?
    2. How do i convert the received binary data into pdf ?
    Regards & Thanks,
    Bharath Kaushik Krishnan

    Check thread Data Conversion
    if it is useful for you.

  • Convert Binary Data into Pdf & send it as attachment in a mail from R/3

    Hi,
    Scenario:
    The interactive form saved in WebDynpro Application is sent to R/3 in binary format. It has to be converted into pdf and sent it as an attachment in mail to the respective person in workflow.
    Kindly help on these issues :
    1. How to receive the binary data in R/3 sent by the WebDynpro Application ?
    To my knowledge we can receive the binary in XSTRING data type. Plz correct me if am wrong.
    2. How do i convert the received binary data into pdf ?
    Thanks,
    Bharath Kaushik Krishnan

    HI Bharath,
    I think You can reuse teh XString for binary data.there are certain function modules in R/3 for creating pdf/for sending it as pdf attatchment.please search in abap forums you will find more information
    With Regards
    Naidu

  • Convert a date to string

    hi,
    I have a got a date d = Wed Nov 05 00:00:00 GMT 2008
    i need to convert this into a string of the format MM/dd/yyyy.

    You may use SimpleDateFormat class
    --Sachin.                                                                                                                                                                                                                   

  • Best way to put binary-data into string?

    Hi there!
    What I want to do is to transfer binary data via HTTP/GET so what I have to do is to transfer binary data into a string.
    Currently I do this the follwing way:
          byte[] rawSecData = new byte[4]; //any binary datas
          ByteArrayOutputStream secBOS = new ByteArrayOutputStream(4);
          DataOutputStream secDOS = new DataOutputStream(secBOS);
          for(int i=0; i < rawSecData.length; i++)
            secDOS.writeByte(rawSecData);
    secDOS.flush();
    String secData = secBOS.toString();
    System.err.println("Lenght of resulting String: "+secData.length());
    I know that this way already worked fine, however I now set up my system up again with another linux-distro and now strange things happen.
    e.g. the secData string differs in lenght from run-to-run between 2 and 4 and I don know at all why?
    Transferring the binary-stuff into string-stuff (e.g. short-binary 255 255, String: 65536) is not possible for me because of various reasons.
    The funny thing is that I remeber that this already worked some time ago and I can figure out why it now doesnt...
    Please help!

    First of all thanks a lot for your help!
    Yes, I already think its an encoding problem, but how can I specify the encoding in my application in a portable way. I dont have an idea what to do.
    My applikation should run as applet on many different 1.1+ VMS (msjvm, netscape-1.1.5, ...).
    Thanks again, lg Clemens

Maybe you are looking for

  • Using importdata to import xml data into dynamic PDF form

    Hi again, Me and my colleagues have a problem using the importData service to import some xml data into an empty PDF form (represented as an XFA input variable). In the server log I get the error that Only XDP data is supported for XFA forms, however

  • P.O validation

    Hi, i have made user exit program. program logic is as follows. we maintain a 'z' table with material code & WBS element and when ever we create a p.o with account assingment 'q'. it needs to check the 'z' table whether the material code along with w

  • How to create new user, with same personal files, for troubleshooting?

    I cannot find this answer in "Finder Help", nor in the Community discussions thus far. What I must do to troubleshoot the spinnign beach ball: My next step: I must troubleshoot my friend's iMac running Mac O.S 10.6.8 by setting up a new user, called

  • How to restore SMS and iMessage from itunes backup?

    Hi, I made a backup with itunes, and made a clean install of iOS 7.1.1. When I was going to recover all my data, iTunes told me that the backup was corrupt (and I only had that backup) Using iBackUp Bot and the information linked to iCloud, I was abl

  • Unable to post FICA records to GL

    Hi All, I am getting the error message F5670 when I am trying to post to GL thro FPG1 transaction. The error is as follows: No account is specified in item 0000000001                                                                                Mess