Binary Stored as String

Hi,
I am storing Binary Data into Varchar(Max) field, while migrating to another binary field, since it is stored earlier in the table with the varchar and then insert into Binary will again convert the string into Binary data. which is corrupting   data.
How to Insert Varchar(max) field to Binary Field in another table
Thanks, Parth

Hi Parth,
Regarding your description, the binary data is stored in a varchar(max)  column, do you mean the values of the varchar(max) column are like ‘0x5445535420535452494E47’? So when you tried to migrate it to a binary field, the string ‘0x5445535420535452494E47’
was converted into binary other than the value the string stands for?
If my understanding is correct, you may reference the code as below, just use the built-in
COVERT with one more optional parameter, you can read more details under 
Binary Styles in the covert page.
DECLARE @srcTbl TABLE(str1 VARCHAR(MAX))
DECLARE @tarTbl TABLE(str1 VARBINARY(MAX))
INSERT INTO @srcTbl SELECT '0x5445535420535452494E47'
INSERT INTO @tarTbl SELECT CONVERT(VARBINARY(MAX),str1,1) FROM @srcTbl -- 1 here is necessary
SELECT str1 FROM @srcTbl
SELECT str1 FROM @tarTbl
If you have any question, feel free to let me know.
Best regards,
Eric Zhang
TechNet Community Support

Similar Messages

  • How can I convert the variable expression stored as string back to variable expression

    How can I convert the variable expression stored as string back to variable expression?
    I am storing the expression enterd in the TSExpresssionEditControl as simple string and want to convert back to expression since I want to get the data type of that expression.

    pritam,
    I'm not sure what you're trying to do exactly. If you are trying to get the value of a variable and you only have the name of value in a string, then you can use Evaluate() to get its value. If you want the data type, my advise is to use the GetPropertyObject() API method and just pass in the loop up string. Then you'll have a handle to the data object and then proceed from there.
    Regards,
    Song D
    Application Engineer
    National Instrument
    Regards,
    Song Du
    Systems Software
    National Instruments R&D

  • 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

  • How long charactors can stored in 'STRING' type?

    HI
    I'm just curious how long charactors can stored in 'string' type.
    and if there is limit number to store what kind of type is unlimited length type?
    and is it possible send a parameter page to page with 'form'  'post' way unlimited length of string?
    and is there any type of DB field which is save last number of records  automatically when one record is inserted like MANDT?
    MANDT is client number though.
    Regards.

    Here is what ABAP key word documentation says about string
    The elementary data type STRING is similar to data type C and refers to a variable-length string. Accordingly, the elementary data type XSTRING is similar to data type X and refers to a variable-length byte sequence.
    In contrast to a C or X field, the length of a string is not static but variable and adjusts itself to the current field content at runtime. Dynamic memory management is used internally. Strings can have any length.
    The initial value of a string is an empty string with length 0. A structure containing a string is seen as deep. A deep structure cannot be used like a C field. Strings can be displayed in the ABAP Debugger and used in the ABAP Dictionary.
    It is not yet possible to use strings in screens or database tables. However, strings can be stored in database tables as clusters using EXPORT and transferred using IMPORT.
    As far as I know the limit is 4 Giga Byte which equals more or less no limit. I donnot expect that you will meet this limit in practice. Its very likely that will run out of memory before you reach this limit.
    In short there is no limit to the data stored in STRING var but the system memory has a limit....
    This can be proved with the below program:
    For the program system dumps with mess.
    "Unable to fulfil request for 127683972 bytes of memory space. "
    here's the test prog.:
    TABLES ekko.
    DATA testmax TYPE string.
    DATA z(16) TYPE i.
    SELECT * FROM ekko.
      CONCATENATE testmax ekko INTO testmax.
      z = strlen( testmax ).
      IF  z = 63841496.
        BREAK-POINT.
      ENDIF.
    ENDSELECT.

  • Binary value to string

    Hi,
    I want to convert binary value to string format. How can i do that if possible please give me sample code.?
    One more question is i want to do reverse thing also that is convert string value to binary format.?
    Waiting for reply

    There are methods in Integer, Long etc for transforming to binary.
    I think there are probably also methods to go from binary to an int. Check out the JavaDoc

  • Find logo from binary or hex string

    HI All ,
    I have file 2 strings one with HEX and one binary this to string is contain the value
    for attachment (logo) ,which FM or method i should use to see the logo, the picture itself  ?
    Regards
    James
    Edited by: James Herb on Feb 28, 2010 5:32 PM

    Hi James,
    This methods and function modules should work for you.
          CALL METHOD cl_binary_relation=>read_links_of_binrel
            EXPORTING
              is_object   = is_object
              ip_relation = 'ATTA'
            IMPORTING
              et_links    = et_links.
        catch
        cx_obl_parameter_error into icx_obl_parameter_error.
          exception_string = icx_obl_parameter_error->get_longtext( ).
        catch cx_obl_internal_error into icx_obl_internal_error .
          exception_string = icx_obl_internal_error->get_longtext( ).
        catch
        cx_obl_model_error into icx_obl_model_error.
          exception_string = icx_obl_model_error->get_longtext( ).
      ENDTRY.
      SORT et_links BY utctime.
      LOOP AT et_links INTO et_links_s.
        v_tbx       = sy-tabix.
        document_id = et_links_s-instid_b.
        CALL FUNCTION 'SO_DOCUMENT_READ_API1'
          EXPORTING
            DOCUMENT_ID                      = document_id
          FILTER                           = 'X '
         IMPORTING
            DOCUMENT_DATA                    = document_data
         TABLES
            OBJECT_HEADER                    = object_header
            OBJECT_CONTENT                   = object_content
          OBJECT_PARA                      =
          OBJECT_PARB                      =
          ATTACHMENT_LIST                  =
          RECEIVER_LIST                    =
          CONTENTS_HEX                     =
         EXCEPTIONS
            DOCUMENT_ID_NOT_EXIST            = 1
            OPERATION_NO_AUTHORIZATION       = 2
            X_ERROR                          = 3
            OTHERS                           = 4.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    ENDLOOP.

  • Executing an Arithmatic Formula stored as String

    Hi All,
    Please help,
    I have similar problem with Mr. Vijayakumar V.
    I need to get result value of an arithmatic formula which stored as string.
    ex:
    zform = '( A / 2 ) + ( B * 1.25 + 2 )'.
    if I have A = 10, and B = 4.
    I do expect the final result to be : 12
    for ( 5 + 7 ) = 12
    Is there any simple way to do this or
    Is there built in function in ABAP to deal with something like this?
    Thank you,

    Hi Oki,
    You can solve your problem by generating subroutine at runtime.
    Please look at sample code below:
    REPORT  z_jr05.
    DATA: code(72) OCCURS 10,
          prog(8),
          msg(120),
          lin(3),
          wrd(10),
          off(3),
          var_string(50),
          p_result  TYPE i.
    var_string  = 'temp_result = ( A * B ) + 199.'.
    REPLACE ALL OCCURRENCES  OF'A' IN var_string WITH '10'.
    REPLACE ALL OCCURRENCES  OF'B' IN var_string WITH '11'.
    APPEND 'PROGRAM SUBPOOL.'                  TO code.
    APPEND 'FORM HITUNG changing p_result.'    TO code.
    APPEND 'data: temp_result type i.'         TO code.
    APPEND  var_string                         TO code.
    APPEND 'p_result = temp_result.'           TO code.
    APPEND 'ENDFORM.'                          TO code.
    GENERATE SUBROUTINE POOL code NAME prog
            MESSAGE msg LINE lin
            WORD wrd    OFFSET off.
    IF sy-subrc <> 0.
      WRITE: / 'Error during generation in line', lin,
      / msg,
      / 'Word:', wrd, 'at offset', off.
    ELSE.
      WRITE: / 'The name of the subroutine pool is', prog.
      SKIP 2.
      PERFORM hitung IN PROGRAM (prog) CHANGING p_result.
      WRITE p_result.
    ENDIF.
    Regards,

  • Binary Search Using String

    I'm trying to perform a binary search on CDs stored in an arraylist but it will only work with the titles with no spaces (Such as Summertime & Heartless but not Dance Wiv Me). Is this a bug or will it simply not work with strings with a space in them? Also when it does work it will return the correct title but the artist and price aren't in the same arraylist index as the search value that was returned.
    * Program to allow customers to purchase CDs from an online store
    * @author (Martin Hutton)
    * @version (24/05/2009)
    import java.util.*;
    public class CDs
        private Scanner input;
        private Scanner in;
        private Scanner sc;
        private CdList aCd;
        CDs()
            this.aCd = new CdList();
            this.menu();
        public void menu()
            int select = 5;
            do
                //Menu Display
                System.out.println("\n\t\t--== Main Menu ==---");
                System.out.println("\n\t\t1. View CDs");
                System.out.println("\n\t\t2. Purchase CDs");
                System.out.println("\n\t\t3. Search CDs");
                System.out.println("\n\t\t4. Sort CDs Titles");
                System.out.println("\n\t\t5. Exit");
                input = new Scanner(System.in);
                select = input.nextInt();
                switch (select)
                    case 1 : this.view();
                    break;
                    case 2 : this.purchase();
                    break;
                    case 3 : this.search();
                    break;
                    case 4 : this.sort();
                    break;
                    case 5 : exit();
                    break;
                    default : System.out.println("Error! Incorrect menu selection!");
            while ( select != 5 );
        public void view()
            System.out.printf("\f");//Clear screen
            System.out.println("\t\t--== Avaiable CDs ==--");
            System.out.println("");
            int size = aCd.getTitle().size();
            //loop to display array date
            for ( int i = 0; i < size; i++ )
                System.out.println( "\t" + i + "\t" + aCd.getTitle().get(i)+ "\t\t\t" + aCd.getArtist().get(i) + "\t\t\t" + aCd.getPrice().get(i) + "\n");
        public void purchase()
           System.out.printf("\f");//Clear screen
           double arrayPurchase[] = new double [15];
           in = new Scanner(System.in);
           sc = new Scanner(System.in);
           double total = 0.0;
           int itemindex = 0;
           System.out.println("How many CDs would you like to purchase? ");
           int amountNumbers = in.nextInt();
           for(int i = 0; i< amountNumbers; i++)
               int q = itemindex;
               System.out.println("Please enter the CD number: ");
               q = in.nextInt();
               //aCd.getPrice().get(q);
               arrayPurchase[i] = aCd.getPrice().get(q);
               total += arrayPurchase;
    System.out.println("\nThe total is: £" + total );
    public void search()
    System.out.println("\t\t--== Search CDs ==--\n");
    System.out.println("Search for a CD: ");
    String lc = input.next();
    Collections.sort(aCd.getTitle());
    int index = Collections.binarySearch(aCd.getTitle(),lc);
    if ( index < 0 )
    System.out.println("Sorry, CD not avaiable");
    else
    // System.out.println(aCd.getPrice().get(index));
    System.out.println( index + aCd.getTitle().get(index) + "\t\t" + aCd.getArtist().get(index) + "\t\t" + aCd.getPrice().get(index));
    this.aCd = new CdList();
    public void sort()
    System.out.println("\t\t-== Alphabetised CD Titles ==--\n");
    Collections.sort(aCd.getTitle());
    int size = aCd.getTitle().size();
    for ( int i = 0; i < size; i++ )
    System.out.println( "\t" + aCd.getTitle().get(i));
    this.aCd = new CdList();
    public void exit()
    System.out.println("\nSystem shutting down...");
    System.exit(0);
    * Write a description of class CdList here.
    * @author (your name)
    * @version (a version number or a date)
    import java.util.*;
    public class CdList
    //instance variables
    private ArrayList<String> title;
    private ArrayList<String> artist;
    private ArrayList<Double> price;
    public CdList()
    //create instances
    title = new ArrayList<String>();
    artist = new ArrayList<String>();
    price = new ArrayList<Double>();
    //populate arrays
    //add titles
    title.add("Boom Boom Pow");
    title.add("Summertime");
    title.add("Number 1");
    title.add("Shake It");
    title.add("The Climb");
    title.add("Not Fair");
    title.add("Love Story");
    title.add("Just Dance");
    title.add("Poker Face");
    title.add("Right Round");
    title.add("Dance Wiv Me");
    title.add("I'm Not Alone");
    title.add("Hot 'n' Cold");
    title.add("Viva La Vida");
    title.add("Heartless");
    //HEX codes
    artist.add("Black Eyed Peas");
    artist.add("Will Smith");
    artist.add("Tinchy Stryder");
    artist.add("Metro Station");
    artist.add("Miley Cyrus");
    artist.add("Lily Allen");
    artist.add("Taylor Swift");
    artist.add("Lady GaGa");
    artist.add("Lady GaGa");
    artist.add("Flo Rida");
    artist.add("Dizzee Rascal");
    artist.add("Calvin Harris");
    artist.add("Katy Perry");
    artist.add("ColdPlay");
    artist.add("Kanye West");
    //RGB Co-ods
    price.add(0.99);
    price.add(0.75);
    price.add(1.99);
    price.add(2.99);
    price.add(2.99);
    price.add(0.55);
    price.add(2.75);
    price.add(1.98);
    price.add(1.25);
    price.add(1.55);
    price.add(0.99);
    price.add(2.55);
    price.add(0.55);
    price.add(1.99);
    price.add(0.99);
    } //end of constructor
    public ArrayList<String> getTitle()
    return ( title );
    } //end method
    public ArrayList<String> getArtist()
    return ( artist );
    }//end method
    public ArrayList<Double> getPrice()
    return ( price );
    }//end method

    It sounds like you are having Scanner woes. Remember that the call:
    select = input.nextInt();Reads the number inputted but not the rest of the line (the enter). Then the next call to readLine will read this.
    Suggestion: do this, to read a number:
    select = input.nextInt();
    String restOfLine =input.nextLine(); //discard

  • 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.

  • Reading a binary file to string variable does not populate correctly

    Hi, I am new to Adobe Air/Flex and I'm trying to read a
    binary file which also contains text in "cleartext". The problem
    I'm having is that when I call FileStream.readUTFBytes method, only
    the first 6 characters are showing up in my string variable
    "contents" when I debug it in FlexBuilder or use a trace command
    and debug it. I have also tried with other types of files but I
    have a similar problem unless it's a non-binary file.
    Am I doing something incorrectly or should I be reading a
    binary file differently than the way I'm reading it currently?
    The source code is shown below.
    TIA,
    Magnus
    <?xml version="1.0" encoding="utf-8"?>
    <mx:WindowedApplication xmlns:mx="
    http://www.adobe.com/2006/mxml"
    layout="absolute">
    <mx:Script>
    <![CDATA[
    import flash.filesystem.File;
    private function readFiles():void{
    var feedFile:File = File.userDirectory.resolvePath( "Local
    Settings/Application Data/Microsoft/Feeds/AppScout~.feed-ms" );
    var stream:FileStream = new FileStream();
    stream.open( feedFile, FileMode.READ );
    var contents:String =
    stream.readUTFBytes(stream.bytesAvailable);
    trace(contents);
    stream.close();
    ]]>
    </mx:Script>
    <mx:Button x="121" y="66" label="Button"
    click="readFiles()" />
    </mx:WindowedApplication>

    It's difficult to tell what it is, it looks like a binary
    pipe symbol but I can copy it from TextPad for example. Some of the
    characters following it cannot be copied from TextPad which I
    assume is because it's null. I can read the whole file in C#/.Net
    and assign it to a string variable without any problems but perhaps
    Air is somewhat limited to binary content.

  • XML validation with DTD stored in String object

    Does anyone know if this is plausible......
    I am trying to validate some XML with a DTD... easy enough, right? The catch is that the dtd is NOT stored in a file somewhere and is also not declared in the XML to be validated. It is stored in a String object (as is the XML file to be validated).
    To clarify - I want to do something like this... but not sure how to incorporate the DTD.
    String dtd = // dtd definition here
    String xml = // xml text here (no URI at the top)
    SAXParserFactory factory = SAXParserFactory.newInstance();
    SAXParser parser = factory.newSAXParser();
    DefaultHandler handler = new DefaultHandler();  // DTD handler??
    parser.parse(new InputSource(new StringReader(xml.toString())), handler);any help would be greatly appreciated.
    thanks in advance,
    Terrance

    I guess it makes the most sense to make the dtd local to the xml. Therefore I would only have one string with both the xml contents and dtd contents. That is how I am going to approach this unless I hear something different.

  • Binary form of string

    Hi All,
    I have written a small program which prints the addresses of the line. But, I don't know how to get the binary form of the string. How the binary form of a string? Will it be 0s and 1s or someother format?
    How to get the binary form of a string?
            try
                // Open or create the output file
                FileReader fr = new FileReader("./Sample.txt");
                BufferedReader br = new BufferedReader(fr);
                String inLine;
                while((inLine = br.readLine())!=null)
                    byte[] data = inLine.getBytes();
                    BinaryRefAddr  binary = new BinaryRefAddr("01",data);
                    System.out.println(binary.getContent());
                    System.out.println(binary.toString());
            catch (IOException e)
            }

    Arivu,
    Could you give an example of what a binary form is?
    For example
    What is the binary form of "2"?
    Is it a String of 0s an 1s such as "00110010"?
    or is an int with value of 50?
    Or what?

  • Doing mathematical formulas with numbers stored as strings

    Hi Everybody.
    I know I must be doing something stupid here, but I just can't see it.
    I'm just trying to do a simple maths formula of one number divide by another. However, one of the numbers is stored as a string.
    I have tried  'X' / Ccur ({'String'}) and even done a seperate formula that succesfully converts the string to a number and  then try 'X' /  ({'conversion formula'}) and still no luck.
    What am I missing and can anybody help please?
    Thanks
    Graham

    Thanks both.
    Works perfectly. Didn't see the ToNumber conversion in the choices available and have not used it before.
    I'll also provide better descriptions as well in the future.
    Regards
    Graham
    Points awarded accordingley  :O)

  • Binary or number string

    Hi...
    How can I know if a string is a binary or number?
    thank you.

    You can only test for a String not containing a binary number like this..
    boolean isNotBinary = ( someString.indexOf( "0" ) == -1 && someString.indexOf( "1 ) == -1 );As a number can be anything with "-012345678eE." and has to adhere to a specific format to qualify as a number AND the fact that the radix makes everything ambiguous determining if a String contains a number and is binary becomes horribly complicated.
    Your definition of number needs to be more tightly defined, integer/long, float/double, fixed decimal and integer/long numbers with different radix need to be considered before you can test for numberness.

  • DateTimeFormatter.format() and date stored as string

    Greetings,
    I need to display some data in a spark data grid and would like to format a date from that data with a labelFunction calling a DateTimeFormatter's format function.
    The date is stored in my ArrayCollection in the following format '2004-05-03 01:03:52.0'
    my formatter is as follows
    <s:DateTimeFormatter id="dateFormatter" dateTimePattern="YYYY-MM-DD" />
    I would like my label function to return something like
    return "Date: " + dateFormatter.format( item[column.dataField]); // where the item[column.dataField] = "2004-05-03 01:03:52.0"
    The date is coming up blank. I'm thinking I need to convert the string "2004-05-03 01:03:52.0" to a Date object first, then pass that into the format() call.
    Is that the way to go? If so, what's the best way to handle that?
    Thanks

    Thank you Sumesh, but the problem was with getting the string converted to a date. I found a solution on
    http://polygeek.com/4137_actionscript3_batbelttime-utilities
    * Convert an MySQL Timestamp to an Actionscript Date
    * Thanks to Pascal Brewing [email protected] for the beautiful simplicity.
    public static function convertMySQLTimeStampToASDate( time:String ):Date{
    var pattern:RegExp = /[: -]/g;
    time = time.replace( pattern, ',' );
    var timeArray:Array = time.split( ',' );
    var date:Date = new Date( timeArray[0], timeArray[1]-1, timeArray[2],
    timeArray[3], timeArray[4], timeArray[5] );
    return date as Date;
    I pass in my string and it gets converted to a Date. I then pass the Date to the DateTimeFormatter.format() and everything works as expected.
    Thanks

Maybe you are looking for

  • How to set UOO(bea_unitoforder) property within BPEL Adapter property

    Hi, In oracle documentation JMS message payload field values can be used as correlation properties. Correlation property aliases are used to define from which payload field the correlation property value is taken. I need to set the correlation proper

  • Is there anyway that i can check my iphone4 RAM?

    My iPhone4 is lagging alot and i'm wondering if there is any way to check it's RAM(Not storage memory). Your opinion please?

  • Imac using usb to hdtv

    My new TV has a USB plug.  Is there a way to display my Macbook screen on the Sharp TV through a usb port on my Macbook?  I need to skype the personal talking being able to talk to the whole room.

  • Agreement Upload in Projects

    Hi, Is there a way we can retrieve the agreement which gets uploaded in Projects. The plan is to develop a web page and display a link to the users wherein they click and retrieve the agreement. Is the agreement stored in the database as BLOB or it i

  • Can I partition a new macbook air hd to run lion and snow leopard?

    I have a new 2011 Macbook Air and it came with Lion. I still have some mission critical programs that are not yet compatable with Lion. Can I partition the HD (I have 256GB) and dual boot with Snow Leopard? I have the Snow Leopard upgrade disk from a