How to split strings into columns

Hi guys,
I have a select like this:
select 'testing1'||'.'||'testing2'||'.'||'testing3' from dualwhich gives me an output like this:
testing1.testing2.testing3How can I split this into 3 columns in SQL PLUS?
Thank you in advance

user643734 wrote:
Thank you guys for all your help.
Hi,
I tried to resolve your problem using somme functions...
I know is a long, long story but it works.
Regards,
Ion--create table_pivot
CREATE TABLE pivot_table(id VARCHAR2(1) primary key, all_concat VARCHAR2(1810));
--add data
insert into pivot_table (id, all_concat) values('x','12345.2829303132.234234.234234.234234');
insert into pivot_table (id, all_concat) values('y','67890.2324252627.234234.234234.234234.332545');
insert into pivot_table (id, all_concat) values('z','11121314.12345.234234.234234.234234.23432.32453245.345435.345435');
insert into pivot_table (id, all_concat) values('a','151617.67890.234234.234234');
insert into pivot_table (id, all_concat) values('b','1819202122.1112131415.234234.234234.234234.345435');
insert into pivot_table (id, all_concat) values('c','2324252627');
insert into pivot_table (id, all_concat) values('h','2829303132.234234.234234.234234.23432.32453245.345435.345435.4325435.345');
insert into pivot_table (id, all_concat) values('r','');
set termout off
--procedures and functions to compile
--1. Main function to format strings
create or replace function fgetformatstring
(v_max_rows numeric, v_crt_row varchar2, v_table_source varchar2, v_save_to_table varchar2, v_option numeric)
return varchar2
is
v_crt_char      numeric:=0;
v_pos_char      numeric:=1;
v_count      numeric:=0;
v_string_out varchar2(500);
v_str_paded     varchar2(10):=',null';
v_length_pad     numeric;
v_diff_pad numeric;
l_crt_row varchar2(1800);
v_char char:=',';
v_delimiter char:='.';
l_save_to_table varchar2(1000);
l_max_rows     numeric;
begin
l_crt_row:=replace(v_crt_row,'.' ,',');
l_save_to_table:=v_save_to_table;
l_max_rows:=v_max_rows;
if v_option=0 then     --get the ',null' to paded in pivot_table     
loop
          v_pos_char:=v_crt_char;
          v_crt_char:=instr(v_crt_row,v_char, v_crt_char+1);
          v_count:=v_count+1;
exit when v_crt_char=0 or v_count=1000;
     end loop;
     v_string_out:=' ';
     v_count:=v_count-1;
     v_diff_pad :=l_max_rows-1-v_count;
if v_diff_pad >0 then                    --nothing to add
     v_length_pad:=length(v_str_paded);-- (+v_char)
     v_length_pad:=v_diff_pad*v_length_pad;
     v_length_pad:=v_length_pad+1;
     v_string_out:=rpad(v_string_out,v_length_pad,v_str_paded);
end if;
end if;
if v_option=1 then     --get definition of v_save_to_table
     v_count:=1;
     v_string_out:=' ';
     loop
exit when v_count=l_max_rows+1 or v_count>=1000;
v_length_pad:=length(v_string_out||'col'||to_char(v_count)||',');
          v_string_out:=rpad(v_string_out,v_length_pad,'col'||to_char(v_count)||',');
          v_count:=v_count+1;
     end loop;
v_string_out:=trim(v_char from v_string_out);
          --v_string_out:='id,'||v_string_out;
          v_string_out:=v_string_out;
end if;
if v_option=2 then     --get position of last comma  
loop
          v_pos_char:=v_crt_char;
          v_crt_char:=instr(v_crt_row,v_char, v_crt_char+1);
          v_count:=v_count+1;
exit when v_crt_char=0 or v_count=1000;
     end loop;
     v_string_out:=substr(v_crt_row,1,v_pos_char-1);
end if;
if v_option=3 then     --get numbers of delimiters(.)
loop
          v_pos_char:=v_crt_char;
          v_crt_char:=instr(v_crt_row,v_delimiter, v_crt_char+1);
--dbms_output.put_line( 'Rows: ' ||v_crt_row|| ' iteration: '||v_count);
          v_count:=v_count+1;
exit when v_crt_char=0 or v_count=1000;
     end loop;
     v_count:=v_count;
     v_string_out:=to_char(v_count);
end if;
if v_option=4 then     --get sql command to create v_save_to_table
     v_count:=1;
     v_string_out:=' ';
     loop
exit when v_count=l_max_rows+1 or v_count>=1000;
v_length_pad:=length(v_string_out||'col'||to_char(v_count)||' varchar2(40), ');
          v_string_out:=rpad(v_string_out,v_length_pad,'col'||to_char(v_count)||' varchar2(40), ');
          v_count:=v_count+1;
     end loop;
v_string_out:=trim(' ' from v_string_out);
          v_string_out:=trim(v_char from v_string_out);
          v_string_out:='create table '|| l_save_to_table ||'('||v_string_out||')';
end if;
if v_option=5 then     --get numbers of delimiters(,) 
loop
          v_pos_char:=v_crt_char;
          v_crt_char:=instr(v_crt_row,',', v_crt_char+1);
          v_count:=v_count+1;
exit when v_crt_char=0 or v_count=1000;
     end loop;
     v_count:=v_count-1;
     v_string_out:=to_char(v_count);
end if;
dbms_output.put_line( 'string: ' ||v_string_out|| ' option: '||v_option);
return v_string_out;
end;
--2.get max items
create or replace function fgetmaxitems
--get the max number of items founded in the pivot_table.all_concat
--before change the points with comma
return numeric
is
v_max                numeric:=0;
v_field               pivot_table.all_concat%type;
v_crt_max numeric:=0;
v_crt_row     varchar(1000);
cursor c1 is
select all_concat from pivot_table;
begin
v_crt_max:=0;
v_max:=0;
open c1;
loop
fetch c1 into v_field;
exit when c1%notfound;
v_crt_row:=v_field;
v_crt_max:=fgetformatstring(0,v_crt_row,'pivot_table','',3);
if v_crt_max>v_max then
     v_max:=v_crt_max;
end if;
end loop;
close c1;
return v_max;
end;
--3. insert the rows in table_dest
create or replace procedure pinsertrow
v_max_rows numeric,
v_all_concat varchar2,
v_source_table_name varchar2,
v_save_to_tablename varchar2
is
v_sql_string      varchar2(1000);
l_all_concat     varchar2(1500);
begin
l_all_concat:=replace(v_all_concat,'.' ,',');
v_sql_string:='('||l_all_concat||')';
v_sql_string:=' insert into ' ||v_save_to_tablename
||' (' ||fgetformatstring(v_max_rows,l_all_concat,v_source_table_name,v_save_to_tablename,1)||')'||
' values'||v_sql_string ;
execute immediate v_sql_string;
end;
--4.procedure to create dinamically <table_dest>
create or replace procedure pcreatesavetable
(v_table_source varchar2, v_save_to_table varchar2)
is
v_sql_string      varchar2(1000);
already_exists exception;
pragma exception_init(already_exists,-955);
v_max numeric;
begin
--clear empty values;
v_sql_string:='delete from ' ||v_table_source|| ' where length(all_concat)=0 or (all_concat) is null';
execute immediate v_sql_string;
v_sql_string:='';
v_max:=fgetmaxitems;
     --create new table
     v_sql_string:=fgetformatstring(v_max,'all_concat', v_table_source,v_save_to_table,4);
dbms_output.put_line( 'sql create : '|| v_sql_string);
execute immediate v_sql_string;
exception
     when already_exists then
--delete old table
     v_sql_string:='drop table ' ||v_save_to_table;
     execute immediate v_sql_string;
     --create new table
     v_sql_string:=fgetformatstring(v_max,'all_concat', v_table_source,v_save_to_table,4);
dbms_output.put_line( 'sql recreate final_table : '|| v_sql_string);
execute immediate v_sql_string;
end;
--5.main procedure
create or replace procedure pmainproc(v_save_to_table varchar2)
is
v_key_pivot      pivot_table.id%type;
v_column_pivot     pivot_table.all_concat%type;
v_max numeric;
v_crt_row          varchar2(1600);
cursor c2 is select y.id , y.all_concat
     from pivot_table y
;     --cursor upon pivot_table 
begin
v_max:=fgetmaxitems;
if v_max <> 0 then
--clear empty values;
delete from pivot_table where length(all_concat)=0 or (all_concat) is null;
--change all points with comma
update
(select x.id, x.all_concat from pivot_table x, pivot_table y where x.id=y.id) b
set b.all_concat=replace(b.all_concat,'.', ',');
-- padd the all_concat with ',null'
update
(select x.id, x.all_concat from pivot_table x, pivot_table y where x.id=y.id and
fgetformatstring(v_max,x.all_concat,'pivot_table',v_save_to_table,5) <> v_max
) b
set b.all_concat=b.all_concat || fgetformatstring(v_max,b.all_concat,'pivot_table',v_save_to_table,0);
--remove last
update pivot_table
set all_concat= fgetformatstring(v_max,all_concat,'pivot_table',v_save_to_table,2)
where fgetformatstring(v_max,all_concat,'pivot_table',v_save_to_table,5) = v_max;
open c2;
loop
fetch c2 into      v_key_pivot, v_column_pivot;
exit when c2%notfound;
v_crt_row:=v_column_pivot;
-- insert data in to final_table
pinsertrow(v_max,v_crt_row,'pivot_table',v_save_to_table);
end loop;
close c2;
end if;
end;
--create table_dest
--the table_dest will be created automatically, so you need admin privilege to run that before compile pcreatesavetable :
connect / as sysdba or connect system/password
--grant create table to hr;
--conne hr/hr;
exec pcreatesavetable('pivot_table','table_dest');
--add data to table_dest
exec pmainproc('table_dest');
set termout on
select * from table_dest;
Table created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
1 row created.
Function created.
Function created.
Procedure created.
Procedure created.
Procedure created.
PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.
COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10
12345 2829303132 234234 234234 234234
67890 2324252627 234234 234234 234234 332545
11121314 12345 234234 234234 234234 23432 32453245 345435 345435
151617 67890 234234 234234
1819202122 1112131415 234234 234234 234234 345435
2324252627
2829303132 234234 234234 234234 23432 32453245 345435 345435 4325435 345
7 rows selected.

Similar Messages

  • How to split string into element ?

    How do you split common string ??
    String dd = "aaa";
    dd.split("a");  // result ["a","a","a"]

    args[0] will not take the entire string Test Hello
    World. It will take only Test, so only one element in
    the string array.What are you talking about?
    He's running the Test program which receives two arguments:
    args[0] = "Hello"
    args[1] = "World"
    But I'm pretty sure he knew that as he lead his post with:
    "Ever have one of those Doh moments"

  • Split String into two

    HI,
    How to Split String into two parts at delimiter

    HI,
    REPORT ZSTRING.
    DATA: LENGTH TYPE I,    
          REMAINING_LENGTH TYPE I ,   
          NEXT_POINTER TYPE I    ,   
          FIRST_HALF(20)  TYPE C ,    
          SECOND_HALF(20) TYPE C ,    
          TEMP TYPE I .
    PARAMETER: WORD(35) TYPE C . "INPUT WORD
    START-OF-SELECTION.
    LENGTH = STRLEN( WORD ).      "Length of the input String
    SEARCH WORD FOR '/'.
        IF SY-SUBRC = 0 .  
          IF SY-FDPOS > 0.   
          MOVE WORD+0(SY-FDPOS) TO FIRST_HALF.  
          ENDIF.  
       TEMP = SY-FDPOS + 1. 
       IF TEMP <> LENGTH.    
       NEXT_POINTER = SY-FDPOS + 1.    
       REMAINING_LENGTH = ( LENGTH - SY-FDPOS ) - 1.    
       MOVE WORD+NEXT_POINTER(REMAINING_LENGTH) TO SECOND_HALF.  
       ENDIF.
    ENDIF.
    WRITE:/'Input String:', WORD .
    WRITE:/'First  Half:', FIRST_HALF.
    WRITE:/'Second Half:', SECOND_HALF.
    *-- End of Program
    Reward Points if found helpfull..
    Cheers,
    Chandra Sekhar.

  • How to convert rows into columns with decode function

    Hi,
    How to convert rows into columns with the help of decode function in oracle.
    thanks and regards
    P Prakash

    say
    col1 col2
    1 10
    2 20
    3 30
    then use
    select col1,
    sum(decode(col2,10,10)) "new1"
    sum(decode(col2,20,20))"new2"
    sum(decode(col2,30,30))"new3"
    from table_name
    group by col1;
    we used sum u can use ny function if wont u have to give the column name i.e col2 name also
    so i think u got it nw
    regards

  • How to split image into smaller (same size) pieces?

    Hi all,
    My question is how to split image into smaller (same size) pieces, using Photoshop elements 13? Could anyone help me with this one?
    Thanks!

    Use the Expert tab in Editor (I think that is what it is called in PSEv.13)
    You may find the grid helpful. Go to View>Grid. It will not print, but will help to orient you. You can set up the gridlines to suit via Edit>Preferences>Guides and Grid. If you want to partition the picture in to 4 uniform pieces, it would be Gridline every 50%, Subdivision 1. Also, go to View>Snap to>Grid.
    Set up the Rectangular marquee tool: If the picture is 6" wide & 4" high, enter width=3in & height=2in.on the tool's option bar. This will be a fixed size.
    Click and select one quadrant, press CTRL+J to place this quadrant on a separate layer
    Repeat for the other 3 quadrants
    You should end up with 5 layers : Background, and layers 1, 2, 3, 4.

  • How to convert rows into column

    Hi,
    can any one help me how to convert rows into column by pl/sql procedure.
    Thanks and Regards

    http://www.oracle.com/technology/oramag/code/tips2004/050304.html
    -- dropping the sample table if exists
    drop table rowstocol
    -- create sample table
    create table rowstocol ( name varchar2(20));
    -- Inserting rows into sample table
    insert into rowstocol values('Amit Zhankar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Piyu Yawalkar');
    insert into rowstocol values('Ashish Ghelani');
    insert into rowstocol values('Aditi Zhankar');
    insert into rowstocol values('Tom Kyte');
    insert into rowstocol values('Oracle');
    -- Following query should be run to create a sql. This result sql should be run to convert rows to column.
    -- The following query uses just the tablename (whose data is to be converted) and name of the column (which is to be converted).
    -- Example taken here is table rowstocol, column name.
    SELECT cc
    FROM (select decode(rn ,1 ,'Select ',null) ||' MAX (CASE WHEN dr = '|| rownum||' THEN DECODE (rn,1, col1) END) '||
    decode(rn,maxr,' col1 from ','||'||chr(39)||','||chr(39)||'|| ') cc,rn,maxr
    from (SELECT ROWNUM rn,count(0) over() maxr FROM rowstocol) order by rn) trows
    union all
    select '(SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn' cc from dual;
    -- The result of this query will do the reqd conversion from row to column.
    -- Replace table rowstocol by your table, column name by your column.
    CC
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn
    Select MAX (CASE WHEN dr = 1 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 2 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 3 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 4 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 5 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 6 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 7 THEN DECODE (rn,1, col1) END) ||','||
    MAX (CASE WHEN dr = 8 THEN DECODE (rn,1, col1) END) col1 from
    (SELECT tabs.col1, DENSE_RANK () OVER (ORDER BY col1,rowid) dr,dense_rank() OVER (order by 1) rn
    FROM (SELECT NAME col1 FROM rowstocol) tabs ) group by rn;
    COL1
    Aditi Zhankar,Amit Zhankar,Ashish Ghelani,Oracle,Oracle,Piyu Yawalkar,Piyu Yawalkar,Tom Kyte
    Edited by: bhooma on Jan 20, 2009 2:44 AM

  • How to convert rows into columns

    Hi,
    How to convert rows into columns of two different tables.
    These two tables have two common columns namely (shipline,pos).
    Let me know if we have any built in functions to do this.
    thank you very much .
    Edited by: 808542 on Dec 7, 2010 8:35 PM
    Edited by: 808542 on Dec 7, 2010 8:37 PM

    Have you tried this first?
    http://forums.oracle.com/forums/search.jspa?threadID=&q=row+to+column&objID=f75&dateRange=last90days&userID=&numResults=15&rankBy=10001

  • How to split a string into columns

    Hello to all ,
    Having a strings like this, where pipe(|) is his delimiter
    10:00 | x1 | 2 | RO | P | Con ausilio  | y1
    10:10 | x2 | 1 | RO |  |  | y2
    10:20 |x3 | 3 |  |  |  | y3
    10:30 |x4 | 3 | RO | N | Con aiuto  | y4
    10:40 |x5 | 1 | RO |  |  | y5
    how can I break it up into columns, for example, the first char(before first pipe) insert in first variable,
    then, after first pipe,  second characters in a other column ans so on
    col1 := '10:00';
    col2 := 'x1';
    col3 := '2';
    col4:= 'RO';
    col5 := 'P';
    col6 := ' Con ausilio ';
    col7 := 'y1';
    col1 := '10:10';
    col2 := 'x2';
    .. and so on
    thanks in advance

    Hi,
    check this:
    WITH mydata(txt) AS
       SELECT '10:00 | x1 | 2 | RO | P | Con ausilio  | y1' FROM DUAL UNION ALL
       SELECT '10:10 | x2 | 1 | RO |  |  | y2'              FROM DUAL UNION ALL
       SELECT '10:20 |x3 | 3 |  |  |  | y3'                 FROM DUAL UNION ALL
       SELECT '10:30 |x4 | 3 | RO | N | Con aiuto  | y4'    FROM DUAL UNION ALL
       SELECT '10:40 |x5 | 1 | RO |  |  | y5'               FROM DUAL
    SELECT TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,1)) col1
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,2)) col2
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,3)) col3
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,4)) col4
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,5)) col5
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,6)) col6
         , TRIM(REGEXP_SUBSTR(txt,'[^|]+',1,7)) col7
      FROM mydata;
    COL1   COL2   COL3   COL4   COL5   COL6            COL7 
    10:00  x1     2      RO     P      Con ausilio     y1   
    10:10  x2     1      RO                            y2   
    10:20  x3     3                                    y3   
    10:30  x4     3      RO     N      Con aiuto       y4   
    10:40  x5     1      RO                            y5    Regards.
    Al

  • Split string into new column

    Hi All,
    Hoping you are able to help.
    I have a table of approx 16 items that I need to split,
    EG:
    CUSTOMER ACCEPTANCE - HAS BEEN DECLINED - DO NOT APPLY TO ACCOUNT
    CUSTOMER ACCEPTANCE -  HAS BEEN ACCEPTED - APPLY TO ACCOUNT
    CUSTOMER ACCEPTANCE - PENDING DECLINE - ESCALATION REQUIRED - RAISED IN PORTAL
    ESCALATION - RAISED - PENDING
    ESCALATION - NOT RAISED - STILL TO BE PROCESSED
    I need to Keep the first two sections, eg CUSTOMER ACCEPTANCE - HAS BEEN DECLINED in one column, and split off the remaining, eg DO NOT APPLY TO ACCOUNT into a new TEMP table to insert as a column into an existing table.
    With little SQL experience, I am having difficulties as they are all of different lengths / criteria etc. Some have 3 hyphens whilst others have 4+
    Is anyone able to help point me in the right direction with this request? I will be greatly appreciated.
    Kind Regards,
    BTMMP

    If you're trying to do this all in a SQL query or stored procedure, then you'll probably get better results on the SQL Server forums. However, if you're working with a PowerShell or VBScript that's doing the work, you're in the right place.
    Here's one example of how you could do what you're describing.  By the way, what do you want to do with the string "CUSTOMER ACCEPTANCE - PENDING DECLINE - ESCALATION REQUIRED - RAISED IN PORTAL"?  Should that be split into "CUSTOMER ACCEPTANCE
    - PENDING DECLINE" and "ESCALATION REQUIRED - RAISED IN PORTAL", or "CUSTOMER ACCEPTANCE - PENDING DECLINE - ESCALATION REQUIRED" and "RAISED IN PORTAL"?
    (In other words, should the script only split off whatever's after the final hyphen, or should it grab the first two pieces of text and split off everything else?)
    Here's an example in PowerShell which assumes that you want to separate out all text after the final hyphen in a string.  It uses a regular expression, though you could accomplish the same thing with Split, Join and Trim operations, if you prefer.
    $string = 'CUSTOMER ACCEPTANCE - HAS BEEN ACCEPTED - APPLY TO ACCOUNT'
    if ($string -match '(.*?)\s*-\s*([^-]*)$')
    $split = $matches[1], $matches[2]
    else
    $split = $string, ''
    Write-Host "Original String: $string"
    Write-Host "First Text : $($split[0])"
    Write-Host "Second Text : $($split[1])"

  • How to Split the Date Column in OBIEE

    Hi,
    We have date column name :To_Date and format is MM/DD/YY HH:MM:SS .
    How do split the date into YEARS,MONTH,DAY as new columns.
    kindly help on this.
    Regards.,
    CHR
    Edited by: 867932 on Nov 23, 2011 10:18 PM

    Hi User,
    All 3 functions can be written in rpd too.In BMM layer, duplicate the date column ->Goto Column Mapping tab-> Expression builder ->Select Functions-> Calendar Date/Time Functions-> Select DayofMOnth function. Your logical column's formula will look like,
    DayofMonth(YourDateColumn)
    Rgds,
    Dpka

  • Split string into its number and alphabetic​al components

    I have a string constant "There are 100 pens and 200 pencils in the box".i want to split it into two parts one consisting of array of numbers i.e. 100 and 200,while the second part should display "There are pens and pencils in the box".
    How should i proceed?

    That looks like homework.
    What have you tried so far and where did you get stuck?
    LabVIEW Champion . Do more with less code and in less time .

  • How to split string based on either space or tab delimitation?

    I'm trying to split a string into 4 fields.  The strings sometimes have space delimitation and sometimes have tab delimitation.  Is there any way to do this in a SELECT, or do I need a couple staging tables, or what?
    I'm trying to work with this.
    Select PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),4) Date,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),3) ID,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),2) Rank1,
    PARSENAME(replace(replace(replace(replace([Column 0],' ','<>'),'><',''),'char(9)',' '),' ','.'),1) Rank2
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    This is similar thread that someone posted a week ago
    Split delimited string into separate columns
    based on space
    My solution was, using a user defined function to split the text:
    Use Master
    Go
    CREATE FUNCTION dbo.udf_SplitString(@InputVal VARCHAR(200), @Delimiter CHAR(1))
    RETURNS @Items TABLE (RowNo TINYINT, ITEM VARCHAR(100))
    As
    BEGIN
    DECLARE @FieldLen TINYINT = 0, @FieldEnum TINYINT = 0, @TempItem VARCHAR(100) = '', @ItemLoop TINYINT = 1
    SET @FieldLen = LEN(@InputVal)
    WHILE @FieldEnum <= @FieldLen
    BEGIN
    IF (SUBSTRING(@InputVal, @FieldEnum + 1, 1) = @Delimiter OR @FieldEnum = @FieldLen) AND @TempItem <> ''
    BEGIN
    INSERT @Items (RowNo, Item)
    VALUES (@ItemLoop, LTRIM(RTRIM(@TempItem)))
    SET @TempItem = ''
    SET @ItemLoop += 1
    END
    ELSE
    BEGIN
    IF SUBSTRING(@InputVal, @FieldEnum + 1, 1) <> @Delimiter
    BEGIN
    SET @TempItem = @TempItem + SUBSTRING(@InputVal, @FieldEnum + 1, 1)
    END
    END
    SET @FieldEnum += 1
    END
    RETURN
    END
    Next, use the splited data to group based on requirements
    DECLARE @AllData TABLE
    [Column 0] VARCHAR(50)
    INSERT INTO @AllData
    VALUES('20150101 04559690 45 33')
    INSERT INTO @AllData
    VALUES('20150101 045595320 42 48')
    INSERT INTO @AllData
    VALUES('20150101 041198690 44 34')
    INSERT INTO @AllData
    VALUES('20150101 0455222130 41 49')
    INSERT INTO @AllData
    VALUES('20150101 554567450 40 51')
    ;WITH CTE
    AS
    SELECT
    ,Row_Number() OVER(PARTITION BY MainQry.[Column 0] ORDER BY MainQry.[Column 0]) As RowNo
    FROM
    @AllData As mainQry
    CROSS APPLY (SELECT Item FROM Master.dbo.udf_SplitString(REPLACE(MainQry.[Column 0], CHAR(9), ' '), ' ')) As SubQry
    SELECT
    [Column 0]
    ,MAX(CASE WHEN RowNo = 1 THEN Item ELSE '' END) AS [DATE]
    ,MAX(CASE WHEN RowNo = 2 THEN Item ELSE '' END) AS [ID]
    ,MAX(CASE WHEN RowNo = 3 THEN Item ELSE '' END) AS [Rank1]
    ,MAX(CASE WHEN RowNo = 4 THEN Item ELSE '' END) AS [Rank2]
    FROM
    CTE
    GROUP BY
    [Column 0]
    Output
    Column 0 | DATE
    | ID
    | Rank1 | Rank2
    20150101 0455222130
    41 49
    | 20150101
    | 0455222130
    | 41 | 49
    20150101 554567450
    40 51
    | 20150101
    | 554567450
    | 40 | 51
    20150101 041198690 44  34
    | 20150101
    | 041198690
    | 44 | 34
    20150101 045595320 42   48
    | 20150101
    | 045595320
    | 42 | 48
    20150101 04559690 45  33
    | 20150101
    | 04559690 | 45
    | 33
    Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered.

  • Issue with splitting string into multiple lines

    Hi Experts,
    I have a long string s. I want to split this string into several lines each having 72 characters. For this I have done following programming:
         String s = "For the first time it includes a supplementary report attempting to determine if extreme weather
    events can be linked to human-induced climate change. The research team, including members
    of the UK Met Office, identified recent episodes of extreme weather then used a computer to
    estimate the likelihood of the episode happening in a world without increased CO2." ;
         s = s.replaceAll("[\r\n]+", " ");
         char[] sAr = s.toCharArray();
         AbstractList RecepitsList7 = new Bapitrtext.Bapitrtext_List();;
         int start = 0; // start with
         int i = 72 ;
    //     for (int i = 71; i < sAr.length; i++) {
    while (i < sAr.length) {
    //     {     if (sAr[i] == ' ')
                   Bapitrtext Recepits7 = new Bapitrtext();
                   Recepits7.setTextid("TEXT");
                   Recepits7.setTextline(s.substring(start, i).replaceAll("[\r\n]+", ""));
                   RecepitsList7.add(Recepits7);
                   start = i+1;
                   i += 72;
         input.setText(RecepitsList7);
    The output of program is as below:
    For the first time it includes a supplementary report attempting to dete
    mine if extreme weather events can be linked to human-induced climate
    hange. The research team, including members of the UK Met Office, iden
    ified recent episodes of extreme weather then used a computer to estim
    te the likelihood of the episode happening in a world without increased
    Here as we can see last characters are getting deleted by program. For example in first line
    determine 'r' is missing in extreme right.
    In 3rd line c is missing in extreme left (word change is needed. Program
    prints hange.
    Also in 3rd line extreme right 't' is missing
    Also in 4th line extreme right 'a' is missing
    Also the last line is not being printed. In last line "CO2." " should appear.
    There are two issues:
    1. Why last word of each sentence is not being printed?
    2. Why last sentence is not being printed?
    I am struggling since last 2 days. Please help. I made all changes like replacing 72 by 71 etc.
    By making such changes, I am able to print first line correctly. However under all cases
    last character of 2nd line onward is not getting displayed.
    Also last line is not getting displayed. I did every thing like using while instead of for loop etc.
    Kindly help.
    Regards,
    Gary
    Edited by: 945655 on Jul 10, 2012 11:39 PM

    String s = wdContext.currentContextElement().getExpense_Text();
         s = s.replaceAll("[\r\n]+", " ");
         char[] sAr = s.toCharArray();
         AbstractList RecepitsList7 = new Bapitrtext.Bapitrtext_List();;
         int start = 0; // start with
         int i = 72;
    while (i < sAr.length) {
                   Bapitrtext Recepits7 = new Bapitrtext();
                   Recepits7.setTextid("TEXT");
                   System.out.println(s.substring(start, i));
                   RecepitsList7.add(Recepits7);
                   start = i+1;
                   i += 72;
         input.setText(RecepitsList7);
    Edited by: 945655 on Jul 11, 2012 2:25 AM

  • How to Split field  into multiple fields in  Import Manager without  delem

    Hi
      Is there any method to Split a record in MDM without using delimitter?
    I dont want to use any delemitter  My field content in Source is  PRODLABELPACK and I want to split it into 3 fields in destination  Field1= PROD
    Field2=LABEL   Field3=PACK
    I know how to split it if the content is PROD_LABEL_PACK .But we dont want to use delimiter in the firld and want to use some substring function
    Regards
    Prashant

    You Can use below FM  SWA_STRING_SPLIT -
    First Use READ_TEXT FM.
    then loop into
    loop at tline.
    Here use 'SWA_STRING_SPLIT' -> Pass tdline and append the text into other internal table.
    endloop
    Thank you
    Seshu

  • Pages (iWork 06) won't split cells into columns past a certain number...

    I'm trying to split a number of cells into columns (only one column of cells selected at a time). It worked fine with 5 out of the 15 columns that I have, but now when I highlight a column's worth of cells and right click "split into columns" is grayed out. Why?
    I changed the page size and made it huge in case that was limiting the overall table dimensions or anything like that, but it's still not working. Thanks!

    Does the ext directory have the php_oci8.dll? In the original steps the PHP dir is renamed. In the given php.in the extension_dir looks like it has been updated correctly. Since PHP distributes php_oci8.dll by default I reckon there would be a very good chance that the problem was somewhere else. Since this is an old thread I don't think we'll get much value from speculation.
    -- cj

Maybe you are looking for

  • SSO to third party in EP 7.0 (SP-21)

    Folks, Could you please advise if we can do SSO to third party vendor using SAML/SAP logon Ticket in EP 7.0 (SP-21). Let me explain a bit: We have EP 7.0 (SP-21), after initial logon to portal we can access backend SAP ECC6/BI applications (WebDynpro

  • Problem with WRT330 n

    I have wireless router WRT330 N The router always rest and I don't know why !! plz help meeeeeeeeeeeeeeee

  • Adding *67 to all outbound calls NOT in my contacts?

    Sorry if this is a redundant question, I could not find an answer on a search...is there any way to either block caller ID, or automatically insert a *67 when calling numbers NOT in my contacts? Thanks.

  • 2008 Macbook Air Screen Hinge Problem

    Hi all, so my 2008 Macbook Air's hinge got a little loose, and I was told Apple would replace it for free, so I took it to them. HUGE MISTAKE. After the hinge was replaced the screen didn't fully line up when the laptop was closed and the screen star

  • How to XI u0097 SRM, which adapter type should i use

    I want to get info from SRM, and feed back the response to SRM Is there any detail about this? and any link? Thanks