Add space in the string

Hi
I have a varchar column, the data in the column have no space in between. I want to keep space after every 20 characters while I select data from this column, how can I acheive this.
thanks
Royal Thomas

If so, try this:
DECLARE @longStrings TABLE (string VARCHAR(MAX))
INSERT INTO @longStrings (string) VALUES
('123456789012345678901234567890123456789012345678901234567890'),('123456789012345678901234567890123456789012345678901234567890123456'),('12345678901234567890123456789012345678901234567890123456789012345678901234567890')
;WITH rString AS (
SELECT 1 as seq, string, LEFT(string,20)+' ' AS part, RIGHT(string,LEN(string)-20) AS remaining
FROM @longStrings
UNION ALL
SELECT r.seq + 1, r.string, r.part+LEFT(remaining,20)+' ', CASE WHEN LEN(remaining) >= 20 THEN RIGHT(remaining,LEN(remaining)-20) ELSE '' END
FROM rString r
INNER JOIN @longStrings ls
ON r.string = ls.string
WHERE remaining <> ''
SELECT string, max(part)
FROM rString
GROUP BY string

Similar Messages

  • How to add spaces at the end of record

    Hi Friends,
    i am creating a file which contains more than 100 records.
    In ABAP i have internal table with on field(135) type c.
    some time record have length 120, somtime 130 its vary on each record.
    but i would like to add space at the end of each record till 135 length.
    Can you please help me how to add speace at the end of record.
    regards
    Malik

    So why did you said that in your first posting? My glass sphere is out for cleaning...
    Instead of type c use strings and add spaces until they have the appropriate length.
    loop at outtab assigning <pout>.
      while strlen( <pout>-val ) < 135.
        concatenate <pout>-val `` into <pout>-val.
      endwhile.
    endloop.

  • How do you add space between the Series Name and the chart?

    I'm trying to format a 3D pie chart and the series name is nearly unreadable depending on the angle. I would like to add some space between the series name and the chart.

    On my charts, I just select the legends and drag them away from the chart. Hopefully this example helps:
    Regards,

  • Fastest way to add spaces to a String?

    I need to have strings with a fixed width containing variable length text. The following (working) code does this with stupid if() and for() statements:
            StringBuffer levelName = new StringBuffer(record.getLevel().getName());
            if (levelName.length() < LEVEL_WIDTH) {
                int g = LEVEL_WIDTH - levelName.length();
                for (int i = 0; i < g; i++) {
                    levelName.append(' ');
            sb.append(levelName); As this code is called a lot of time, i'm looking for a more efficient way to expand strings to a fixed width (by adding spaces). is there a better performing solution?

    In this simple padding situation, there's no real advantage to using a StringBuffer over just a char array:
    //(1) do this once:
    char[] spaces = new char[LEVEL_WIDTH];
    char[] buffer = new char[LEVEL_WIDTH];
    java.util.Arrays.fill(spaces, ' ');
    //(2) Do this whenever you pad:
    int len = yourString.length();
    if (len < LEVEL_WIDTH) {
        System.arraycopy(yourString, 0, buffer, 0, len);
        System.arraycopy(spaces, 0, buffer, len, LEVEL_WIDTH-len);
        yourString = new String(buffer); //(*)
    }Notes:
    1. First off, it should be noted that trying to optimize before profiling could be a waste of time: what if the next operation is a database query that takes 100,000 times are long as this?
    2. arraycopy is a native op, so it should run faster than a loop. Arrays.fill calls arraycopy, btw.
    3. For efficiency, I reuse arrays buffer and spaces.
    4. The char array is copied in line (*). It would be nice to avoid that copying: to copy the original string and append padding directly into the strings buffer, but I don't see how that's possible. Using a StringBuffer involves at least as much copying, as far as I can tell (he says, staring at the source code)...

  • Why dreamweaver add space in the code when i do this:...?

    Hi,
    look at those pictures below.. Those are the steps to show how dreamweaver reacts after a series of actions with part of the code in CODE VIEW...

    Hi Masa,
    Well the answer lies in how you are adding the indentation for better reading.
    I assume you added space of tab to add indentation. So you are doing that in reduced window width and your text wraps as per the width. But when you again resize the window to full lenght your text takes  full space and the spaces and tabs you added for indentation are moved into text itself which is normal (since you have added that space to text).
    So DW is now adding any space it is the space you added for indentation which is showing up when you go to full width view.
    Don't use such indentation for reading in code and anyways HTML will leave out such whitespaces when page renders.
    Hope that helped
    -Vinay

  • Add space to the end of textfield value

    Hi,
      I have a requirement where I need to append 2 spaces to ta textfield at the end of field for certain conditions.
    I used Concat() function and if I checked the length, it added the space successfully in the scripting. But in the output display, it is not considering the space to the text. I need this particularly because all my text fields are right alligned and if I have a space appended to the text at the end, I should able to see it in the form
    for ex:
           I need     Martin     ( for the first text field)
                       Martin       ( with two spaces appended)
    I need the output in the above way.
    Can you please help me out.
    Sample code I wrote on scripting:
    var raw = $.rawValue
    $.rawValue = Concat(raw, Space(2))
    If I check the length of field, I could see that length got increased by 2. But I cannot display in the output.
    Thanks in advance,
    k.c

    Hi,
    Instead of inserting white spaces script to change the right indent:
    if (this.rawValue == "Martin")
        this.para.marginRight = "1.5mm";
    else
        this.para.marginRight = "0mm";
    This is Javascript, but I am sure it will run in FormCalc.
    N.

  • How to add spaces to the column value to make it up specifi length string please

    Hello There,
    Could you please guide me here to solve this issue,
    in my column (named as State) contains values as below
    California
    Washington
    Utah
    Connecticut
    Massachusets
    in the output how can i add a spaces to make up every column values as 15 length (for ex, Utah is 4 length then need to add 11 spaces, California is 10 would like to add 5 spaces)
    i tried below but no use in Sql 2008 R2
    SELECT  distinct state
       state
    +SPACE(35-len(state)),
    len(state+SPACE(35-len(state)))
    FROM dbo.ordersInfo
    Thank you in advance
    Milan

    Fixed length CHAR(n) data in SQL is automatically padded with spaces. Either change the column's data type or cast to it. Also, the ISO-11179 rules are that the column should be "state_name" and not just the root attribute "state" -- state_code, state_population,
    etc are a few of the confusions you created. 
    Another rule of RDBMS is that we do not do display formatting in the data. That is what presentation layers do. Why are you trying to fake COBOL in SQL? 
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • How to add space before a string a variable.

    Hi,
    If i have a string variable  ' 80 '.I want it as '    80 ' ie some space appended before it.
    I used  concatenate '   '    variable into variable..Its not working.How to do it??
    Thanks.

    check below code
    Concatenate ' ' string into string respecting blanks.
    <b>
    ... RESPECTING BLANKS</b>
    Effect
    The addition RESPECTING BLANKS is only allowed during string processing and causes the closing spaces for data objects dobj1 dobj2 ... or rows in the internal table itab to be taken into account. Without the addon, this is only the case with string.
    Note
    With addition RESPECTING BLANKS, statement CONCATENATE can be used in order to assign any character strings EX>text - taking into account the closing empty character - to target str of type string: CLEAR str. CONCATENATE str text INTO str RESPECTING BLANKS.
    Example
    After the first CONCATENATE statement, result contains "When_the_music_is_over", after the second statement it contains "When______the_______music_____is________ over______" . The underscores here represent blank characters.
    TYPES text   TYPE c LENGTH 10.
    DATA  itab   TYPE TABLE OF text.
    DATA  result TYPE string.
    APPEND 'When'  TO itab.
    APPEND 'the'   TO itab.
    APPEND 'music' TO itab.
    APPEND 'is'    TO itab.
    APPEND 'over'  TO itab.
    CONCATENATE LINES OF itab INTO result SEPARATED BY space.
    CONCATENATE LINES OF itab INTO result RESPECTING BLANKS.
    Rewards if useful.........
    Minal

  • URGENT : How to add spaces in the outbound file

    Hi Gurus,
    I am writing data from SAP to a Unix file via an ABAP program.
    The file has one record with 4000 characters with 2000 spaces in between the datas.
    Is there any command to add these spaces ? Or I have to go through a loop to add them ? I cannot leave them and assume that they will be spaces by default,as this is causing some error in Unix side.
    Please help,this is urgent.
    Regards,
    Sandip.

    heyy i could find the solution to it....so am closing the thread..thanksss

  • To add space at the begining of a file

    Hi,
      i have a requirement, when you transfer data to a file it should start writing data from 10th place.
    ex: data p_ext LIKE rlgrap-filename.
         data: var1(9)  type c value 'test data'.
         data: hold(100) type c.
         p_ext = '/devabap/if/daily/out/test1.rg'.
    open dataset p_ext for output in text mode encoding default.
    concatenate c_blank
                       var1
                       into hold
                       separated by cl_abap_char_utilities=>horizontal_tab.
    transfer cont to p_ext.
    close dataset p_ext.
    When i do this and check the file contents in AL11.
    i can see the contents like
    #test data.
    but i want to know how this can that be changed to like
                     #test data.
    Regards,
    Raghavendra.

    Hi ,
      When you use concatenate using separating , the separating string  does not come in the first place , it just comes between the values you are concatenating .
    so to acheive your result , you should again concatenate  cl_abap_char_utilities=>horizontal_tab , to your result before you transfer it to the file.
    concatenate cl_abap_char_utilities=>horizontal_tab cont into cont.
    or you can do is use the shift command after the concatenate operation.
    Here is a sample
    shift cont by 10 places RIGHT.
    Regards
    Arun
    Edited by: Arun R on Jan 22, 2009 1:29 PM

  • How to pad spaces at the end of a string

    Hi All,
    I am new to ABAP and need help to achieve this functionality
       I have to build a string with fixed lenth . my input string
      is always lesser than equal to X . I need to calculate and
       add that many spaces at the end of the input string .
      I tried to do this and getting the following error
        please help on this :
      if strlen( t_resultc ) < 525.
      RFILL(t_resultc,' ',525)
      endif.
      Error : Comma without preceding colon(after RFILL(T_RESULTC ?)
    Q: Can I use RFILL with out Select statement in a ABAP program
    Thanks & Regards
      KLK

    Hi,
    Try the following code but kindly make a note..
    Note:-USE quote like this  ` `, Instead of normal single quotes ‘ ’
    WHILE strlen( T_RESULTC ) < 525.            “Check the length   
       CONCATENATE  T_RESULTC ` ` INTO T_RESULTC. ”Add spaces at the end   
    ENDWHILE.
    Hope this helps,
    Andrew

  • How do I add a space to the toolbar in Firefox 29.0? I can grab a space from empty areas and move it around, but where do I find a "space" icon to ADD a space?

    It has been useful in past versions of Firefox to be able to add (a) space(s) between icons on the toolbar in order to create groups of icons and/or separate icons by class or function. In Firefox 29.0, I discovered how to "grab" (click and drag) a space from open areas on the toolbar and move it to another part of the toolbar. But how can I add spaces to the toolbar? In past versions, there used to be a space icon in the customize menu set that could be dragged to the toolbar for that purpose.

    You can get around this problem by installing the "Classic Theme Restorer Add-on" available at: https://support.mozilla.org/en-US/kb/how-to-make-new-firefox-look-like-old-firefox
    While returning the squared-off look to your tabs, instead of the newer, rounded version - it also gives returns the option to add spaces; variable size spaces, and separators to your tool-bars.

  • Insert space before the capital letter in a word

    Hi,
    I have a column with list of names like
    reports
    admissionPage
    topHighCost
    requestedReports
    Like this there will be many rows. I want to add space before the capital letter.
    This is a rdl query. Is it is possible to do in SSRS? Or we should do in Tsql? Please help me in this issue.
    Thanks in advance..
    BALUSUSRIHARSHA

    Its going to be pretty complicated, in my opinion, to do this in SSRS.
    For t-sql, I developed a function for you.
    CREATE FUNCTION fn_text_with_space(@STRING VARCHAR(MAX))
    RETURNS
    VARCHAR(MAX)
    AS
    BEGIN
    DECLARE @NEWSTRING VARCHAR(MAX) = '';
    declare @count int = 1;
    WHILE @COUNT <= LEN(@STRING)
    BEGIN
    IF SUBSTRING(@STRING, @COUNT, 1) COLLATE Latin1_general_CS_AS = UPPER(SUBSTRING(@STRING, @COUNT, 1)) COLLATE Latin1_general_CS_AS
    BEGIN
    SET @NEWSTRING = @NEWSTRING + ' ' + SUBSTRING(@STRING, @COUNT, 1);
    END
    ELSE
    BEGIN
    SET @NEWSTRING = @NEWSTRING + SUBSTRING(@STRING, @COUNT, 1);
    END
    SET @COUNT = @COUNT + 1;
    END
    RETURN @NEWSTRING;
    END

  • Add space

    Hi!
    I have a string lets say str... i know what the maximum length of this string can be .Lets assume it to be 30. the data value thats coming into this string is of length 5 chars. what i want to do is to add spaces after the data value upto its maximum length..liek in this case i should add 25 spaces to make it of length 30. Is there any function in java using which i could do it.There is an option for finding the present length and using a loop to add spaces.. but that would be a bit lengthy.. Pls help .. Thanx..

    > PS... i did not get what you meant by 1 of
    loop....and in that length() function
    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/for.html
    In the link above there is given an example of a for loop (statement). The variable int i starts at 1 and gets incremented to a certain value. You need to adjust the initial size and the "end" size of i.
    In the loop you append, or prepend, a white space to your String.

  • Add spaces in XML tag in XI mapping

    Hello guys,
    In an IDoc to XML file scenario within XI, we want to add spaces at the end of an IDoc field that contains text description. When the IDoc gets generated on SAP ECC, the IDoc field is repeated so many times until all the contents are displayed, separated with spaces. However, once the IDoc is sent to XI, the spaces get lost. Is it possible to add a space at the end of each field presence within XI message mapping or they will get lost again ?
    Thank you.
    Best Regards,
    Evaggelos Gkatzios
    Edited by: Evaggelos Gkatzios on Nov 12, 2010 4:49 PM

    > In an IDoc to XML file scenario within XI, we want to add spaces at the end of an IDoc field that contains text description.
    The way IDoc processing works, that does not make any sense at all.
    An IDoc is a fixed length container and the fields are filled with spaces automaticically.
    The IDoc XML generation removes trailing spaces to reduce message size.
    If you need trailing spaces in an XML field, you can add them easily with a UDF. But I think that there are only rare scenarios where you really would need this.

Maybe you are looking for

  • Gnome Display Manager major error?

    GDM is giving me error saying "Oh No something went wrong" I have just installed nvidia drivers from the website and am using intel for display(it wasnt working with nvidia) and bumblebee. systemctl status gdm.service gives: Failed to give slave prog

  • Option claims from CRM are not showing in BW report.

    Hi All, We are having a problem with BW report. The report shows all the claims thatt are created in CRM system( spource sys- CRM). We notices that claims that are called as option claims are not showing in BW report, but they are present in BW. I ha

  • SAP ISU/CCS

    HI , I want to know what is SAP ISU/CCS. Regards, nagaraju.

  • Linking List of Values

    Hi, I have two LOVs within the same region on a page 1) selects all companys User picks a company and it displays in the :company field. 2) selects all fiscal data for the specific company(:company) that was selected by the user in LOV 1. Problem is

  • Is there a way to manually distribute dual CPU resources in Logic Pro 7?

    Hi, Most of the time you can see that only one of the two CPU is used in Logic Pro. When it's saturated, the sound clips and it's over Is there a way to manually distribute processes and apps between the two CPUs? This is possible in Win thru Task Ma