Changing columns into row

HI All,
Please consider the following scenario,
DAta in the data source is in following format
participation number  valuetype     value
1                                ABC             200
1                                DEF              300
1                                EFG              500
1                                XXX             300
But i want it should b stored in following format in DSO ( I dont want to show some value types for.eg XXX in this case)
Participation number    ABC           DEF           EFG
             1                     200            300           500
How can i Do that ....Is ABAP the only option..  if yes ,it will be of great help if somebody give me the code to enter  in the transformation .

Hi guys
I think im having a similar problem.
I have created a progarm that displays username displaying in columns ie.:
User                         edited        day
TSmith                      3                mon
MPeters                   5                thurs
RAndrews              10               wed
I have been requested to change this to columns like
TSmith      MPeters     RAndrews 
3                   5                      10
mon             thurs                 wed
This is how my code looks like:
DATA ls_fieldcat TYPE lvc_s_fcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-fieldname = 'CPUDT'.
ls_fieldcat-scrtext_m = 'Date captured'.
ls_fieldcat-row_pos = 0.
ls_fieldcat-outputlen = 10.
APPEND ls_fieldcat TO pgt_fieldcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-row_pos = 0.
ls_fieldcat-fieldname = 'USNAM'.
ls_fieldcat-scrtext_m = 'User'.
APPEND ls_fieldcat TO pgt_fieldcat.
ls_fieldcat-tabname = 'gt_list'.
ls_fieldcat-row_pos = 0.
ls_fieldcat-fieldname = 'NUMBER'.
ls_fieldcat-scrtext_m = 'Number of entries'.
APPEND ls_fieldcat TO pgt_fieldcat.
Could you please assist?
Thanks

Similar Messages

  • Change Column to Row

    I have a table :
    AA       AF       AF+AA Target    AF+AA  Booking
    1         2               3                           
     4
    5         6                  7                         
     8
    Now I need to make this as:
    Metric               Measure       MetriCode
    AA(AO DP)            1                 02
    AA(AO DP)            5                 02
    AF                        2                08
    AF                        6                08
    AA(AO DP)             3               02
    AA(AO DP)             7               02
    AA(AO DP)             4               08
    AA(AO DP)             8               08
    I need to convert column into row with the "Metric" Name and all my values shouls be "Measure". Also Anything like AA with be AA(AO DP) and AF would be Authorized Futures. Also whatever change tp AA(AO Dp) I need to add metriccode ='08'
    and Authorized Future ='02'.
    How can I get this result?
    SPPandey

    I have a table :
    AA       AF       AF+AA Target    AF+AA  Booking
    1         2               3                           
     4
    5         6                  7                         
     8
    Now I need to make this as:
    Metric               Measure       MetriCode
    AA(AO DP)            1                 02
    AA(AO DP)            5                 02
    AF                        2                08
    AF                        6                08
    AA(AO DP)             3               02
    AA(AO DP)             7               02
    AA(AO DP)             4               08
    AA(AO DP)             8               08
    I need to convert column into row with the "Metric" Name and all my values should be "Measure". Also Anything like AA shall be AA(AO DP) and AF would be Authorized Futures. Also whatever change to AA(AO Dp) I need to add metriccode ='08' and Authorized
    Future ='02'.
    How can I get this result?
    SPPandey
    SPPandey

  • Problem in displaying the data of columns into rows in sap script

    hi,
    i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
    eg, C
        12.1
        Si
        5.5
    it is displaying the data right now like this but i want to display the  data like this:-
    eg, C      Si
        12.1   5.5
    plzzprovide me guidelines how to solve this problem.

    hi,
    i am using this code to display the data:-
    plzz provide me guidelines where i am getting wrong?
    TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
    PROTECT
    IF &I_FINAL-PRUEFLOS& NE '000000000000'
    &I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ELSE
    &I_FINAL-MAKTX(23)&     
    &I_FINAL-kurztext(25)&
    &I_FINAL-original_input(8)&
    ENDIF
    ENDPROTECT
    ITEMHEAD
    POSITION WINDOW
    SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
    BOX FRAME 10 TW
    BOX HEIGHT '1.35' LN INTENSITY 20
    IF &PAGE& = '1'
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
    For horizontal line at top
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
    ELSE
    COLUMN LINES...
    END OF COLUMN LINES...
    BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
    BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
    BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
    BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
    ENDIF
    LINEFEED
    NEWPAGE
    NEW-PAGE
    provide me guidelines to solve this problem.
    Edited by: ricx .s on Mar 13, 2009 5:58 AM

  • How to display the rows in to columns and columns into rows?

    DES:- I know by using pivot and unpivot you can convert rows into columns and columns into rows but i don't know how to write the syntax?

    Hi,
    Besides the places Martin mentioned above, there are many examples in the forum FAQ:
    https://community.oracle.com/message/9362005#9362005
    For an example of both PIVOT and UNPIVOT in the same query, see
    http://forums.oracle.com/forums/thread.jspa?threadID=920854&tstart=0

  • To convert columns into row

    Hi All,
    I need help in building view which actually can show columns data as row.
    e.g.
    row is as follows
    Name Age Salary
    ABC 25 10000
    BBC 28 12000
    The above tables data I want to get as
    Name ABC BBC
    Age 25 28
    Salary 10000 12000
    Thanks in advance.

    Even if I don't really understand such requirement, I wrote some times ago such function to play around that :
    Re: Converting Columns into rows
    Nicolas.

  • How to turn columns into rows

    Hi. Does anyone know how to turn columns into rows ie:
    select field1, field2, field3, field4, field5 from table
    desired result:
    field1 field2
    field1 field3
    field1 field4
    field1 field5
    Thank you!

    Something like this ?
    select field1
    , case n.l
    when 1 then field2
    when 2 then field3
    when 3 then field4
    when 4 then field5
    end field
    from table
    , (select level l from dual connect by level <= 4) n

  • Converting columns into rows

    Dear all....I need to convert all columns into rows in a table. For example table has following columns:
    Emp_Cod........Val1......Val2......Val3
    1 a b c
    Now I wish that each column should display as a value like:
    Emp_Cod........Val1
    1 a
    1 b
    1 c
    Now the one way to solve this job is to write a union statement for each column but for this I'll have to write equal number of select statements as there are columns.
    What I need that is there anyway to write minimum code for this job, is there any alternate way???

    SQL> with t as(select 1 emp_code, 'a' val1, 'b' val2, 'c' val3 from dual)
      2  select*from t unpivot(v for c in(val1,val2,val3));
    EMP_CODE  C     V                                                      
            1  VAL1  a                                                      
            1  VAL2  b                                                      
            1  VAL3  c                                                      
    SQL> col COLUMN_VALUE for a20
    SQL> with t as(select 1 emp_code, 'a' val1, 'b' val2, 'c' val3 from dual)
      2  select*from t,table(sys.odcivarchar2list(val1,val2,val3));
    EMP_CODE  V  V  V  COLUMN_VALUE                                        
            1  a  b  c  a                                                   
            1  a  b  c  b                                                   
            1  a  b  c  c                                                   

  • Transpose columns into rows

    hi ,
    i need to transpose columns into rows ,
    i know i can use the UNION ALL but my num of columns will most likely not be fixed so how can i do that ?
    pls advise

    This is from one of the forms link,, i reallyy dont know the link, but i guess this is "adrains" code
    SQL> WITH ilv AS (
      2      SELECT str || ','                                   AS str
      3      ,     (LENGTH(str) - LENGTH(REPLACE(str, ','))) + 1 AS no_of_elements
      4      FROM   t
      5      )
      6  SELECT RTRIM(str, ',')                              AS original_string
      7  ,      SUBSTR(str, start_pos, (next_pos-start_pos)) AS single_element
      8  ,      element_no
      9  FROM  (
    10         SELECT ilv.str
    11         ,      nt.column_value AS element_no
    12         ,      INSTR(
    13                   ilv.str,
    14                   ',',
    15                   DECODE(nt.column_value, 1, 0, 1),
    16                   DECODE(nt.column_value, 1, 1, nt.column_value-1)) + 1 AS start_pos
    17         ,      INSTR(
    18                   ilv.str,
    19                   ',',
    20                   1,
    21                   DECODE(nt.column_value, 1, 1, nt.column_value)) AS next_pos
    22         FROM   ilv
    23         ,      TABLE(
    24                   CAST(
    25                      MULTISET(
    26                         SELECT ROWNUM FROM dual CONNECT BY ROWNUM < ilv.no_of_elements
    27                         ) AS number_ntt )) nt
    28        );
    ORIGINAL_STRING                 SINGLE_ELEMENT  ELEMENT_NO
    X,Y,Z                           X                        1
    X,Y,Z                           Y                        2
    X,Y,Z                           Z                        3
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  XXX                      1
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  Y                        2
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  ZZ                       3
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  AAAAA                    4
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  B                        5
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  CCC                      6
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  D                        7
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  E                        8
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  F                        9
    XXX,Y,ZZ,AAAAA,B,CCC,D,E,F,GGG  GGG                     10
    13 rows selected.
    Note that the above SQL performs the following steps:
        * determines how many elements are in each string (WITH clause);
        * for each string, generates a collection of n elements (TABLE expression), where n is the derived number of elements in the string. Note in particular the use of "less than" in the "CONNECT BY ROWNUM < ilv.no_of_elements" on line 26. In all versions other than 10.1.x, this will need to be "CONNECT BY ROWNUM <= ilv.no_of_elements" (i.e. "less than or equal to"). There is an unusual bug with this row-generation technique in 10.1 that generates an additional row from the CONNECT BY;
        * uses the generated rows in a Cartesian Product with the original data to generate n rows per string, based on the above definition of n;
        * calculates the start and end position of each element in each string (INSTR); and
        * cuts each element from each string (SUBSTR).

  • Change column to rows

    Hi experts,
        How to change columns to rows and row to columns in executable program . Any function modules(se 37)
    or any class(se24) are there please give me suggestions.
    Thank you,
    dinesh reddy.

    Hi,
    Use this FM in your ABAP code
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = 'c:/test_data.xls'
    I_BEGIN_COL = '1'
    I_BEGIN_ROW = '1'
    I_END_COL = '10'
    I_END_ROW = '10'
    TABLES
    INTERN = it_tab
    EXCEPTIONS
    INCONSISTENT_PARAMETERS = 1
    UPLOAD_OLE = 2
    OTHERS = 3
    Regards,
    Jyothi CH.

  • One Column into Rows

    I have data in a table that looks like below:
    ColumnA               ColumnB
    123                    abc|cde|fgr
    345                    def|ght|sew
    890                    deq|nmk|lop|lip|fre|dwsThere is no limit on how many values you can have in ColumnB and they are pipe delimited.
    I need to split this one column into rows as:
    ColumnA               ColumnB
    123                    abc
    123                    cde
    123                    fgr
    345                    def
    345                    ght
    890                    fre
    890                    dwsThanks in advance!

    with sample_data as (
                         select 123 columna,'abc|cde|fgr' columnb from dual union all
                         select 345,'def|ght|sew' from dual union all
                         select 890,'deq|nmk|lop|lip|fre|dws' from dual
    select  columna,
            regexp_substr(columnb,'[^|]+',1,column_value) columnb
      from  sample_data,
            table(
                  cast(
                       multiset(
                                select  level
                                  from  dual
                                  connect by level <= length(regexp_replace(columnb || '|','[^|]'))
                       as sys.OdciNumberList
      order by columna,
               column_value
       COLUMNA COLUMNB
           123 abc
           123 cde
           123 fgr
           345 def
           345 ght
           345 sew
           890 deq
           890 nmk
           890 lop
           890 lip
           890 fre
       COLUMNA COLUMNB
           890 dws
    12 rows selected.
    SQL> SY.

  • Convert single column into rows

    hi Gurus,
    I have one table test colums are id and name.
    id number
    name varchar2
    data is like
    id name
    1 xy
    2 xyy
    3 mm
    4 pp
    Now my requirement is to convert single column id into rows
    i,e my output should be of singel rows like :- 1,2,3,4
    How to achive this result .
    I dont have any idea to do this query.
    Please help guys.
    Thanks in advance.
    Vijay

    Well,
    As long as your code doesn't have to run in production, simplest way is:
    WM_CONCAT (but it's not documented)
    or use XMLAGG, it's simpler than a connect by:
    MHO%xe> with t as (
      2  select 1 col, 'xy' str from dual union all
      3  select 2, 'xyy' from dual union all
      4  select 3, 'mm'from dual union all
      5  select 4, 'pp' from dual union all
      6  select 8, 'pp' from dual union all
      7  select 12, 'pp' from dual union all
      8  select 40, 'pp' from dual
      9  )-- actual query, based on id's generated above:
    10  select rtrim(xmlagg(xmlelement(e,col||',')).extract('//text()'),',') col
    11  from   t;
    COL
    1,2,3,4,8,12,40
    1 rij is geselecteerd.

  • How to split columns into rows

    Hi All,
    Below is my table structure:=
    SQL> create table split(id number,value varchar2(200));
    Table created.
    SQL> insert into split values(1,'X,Y,Z');
    1 row created.
    SQL> insert into split values(2,'A,B,C');
    1 row created.
    SQL> commit;
    Commit complete.
    Expected Output
    ID Value
    1 X
    1 Y
    1 Z
    2 A
    2 B
    3 C
    I know the feature of converting rows into columns by listagg in Oracle 11g, but is there any feature to convert rows into columns based on a delemiter..."," in my case.
    Please help....
    Thanks
    Arijit

    >
    is there any feature to convert rows into columns based on a delemiter
    >
    Here is one way
    VAR csv VARCHAR2(100)EXEC :csv := 'abc,de,fg,hij,klmn,o,pq,rst,uvw,xyz';
    The query:
    WITH data AS( SELECT SUBSTR(csv, INSTR(csv,',',1,LEVEL)+1,                     INSTR(csv,',',1,LEVEL+1) - INSTR(csv,',',1,LEVEL)-1 ) token    FROM ( SELECT ','||:csv||',' csv FROM SYS.DUAL ) CONNECT BY LEVEL < LENGTH(:csv)-LENGTH(REPLACE(:csv,',',''))+2 )SELECT token  FROM data;See http://projectwownow.blogspot.com/2010/02/oracle-convert-csv-string-into-rows.html

  • How to convert columns into rows using  transpose function

    Hi
    anybody tell me how to convert columns values into rows using transpose function.

    Since BluShadow went to all the trouble to put it together, someone should use it.
    See the post titled How do I convert rows to columns? here SQL and PL/SQL FAQ
    John

  • Tranforming columns into rows taking to long

    Hi,
    Please help me in tuning the query. I am trying to transform rows into columns. Its taking lots of time almost 13hrs for 500k records.
    select
    decode ( r,
              1,Col_1,
              2,Col_2,
              3,Col_3,
              4,Col_4,
              5,Col_5,
              6,Col_6,
              7,Col_7,
              8,Col_8,
              9,Col_9,
              10,Col_10,
              11,Col_11,
              12,Col_12,
              13,Col_13,
              14,Col_14,
              15,Col_15,
              16,Col_16,
              17,Col_17,
              18,Col_18,
              19,Col_19,
              20,Col_20) Col,
    R ,
    decode ( r,
              1,CASE WHEN SUBSTR(T1.Date_1,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_1,'YYYYDDD') ELSE NULL END,
              2,CASE WHEN SUBSTR(T1.Date_2,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_2,'YYYYDDD') ELSE NULL END,
              3,CASE WHEN SUBSTR(T1.Date_3,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_3,'YYYYDDD') ELSE NULL END,
              4,CASE WHEN SUBSTR(T1.Date_4,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_4,'YYYYDDD') ELSE NULL END,
              5,CASE WHEN SUBSTR(T1.Date_5,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_5,'YYYYDDD') ELSE NULL END,
              6,CASE WHEN SUBSTR(T1.Date_6,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_6,'YYYYDDD') ELSE NULL END,
              7,CASE WHEN SUBSTR(T1.Date_7,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_7,'YYYYDDD') ELSE NULL END,
              8,CASE WHEN SUBSTR(T1.Date_8,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_8,'YYYYDDD') ELSE NULL END,
              9,CASE WHEN SUBSTR(T1.Date_9,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_9,'YYYYDDD') ELSE NULL END,
              10,CASE WHEN SUBSTR(T1.Date_10,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_10,'YYYYDDD') ELSE NULL END,
    11,CASE WHEN SUBSTR(T1.Date_11,5) BETWEEN '001'     AND '366'
                   THEN TO_DATE(T1.Date_12,'YYYYDDD') ELSE NULL END,
              12,CASE WHEN SUBSTR(T1.Date_12,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_12,'YYYYDDD') ELSE NULL END,
              13,CASE WHEN SUBSTR(T1.Date_13,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_13,'YYYYDDD') ELSE NULL END,
              14,CASE WHEN SUBSTR(T1.Date_14,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_14,'YYYYDDD') ELSE NULL END,
              15,CASE WHEN SUBSTR(T1.Date_15,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_15,'YYYYDDD') ELSE NULL END,
              16,CASE WHEN SUBSTR(T1.Date_16,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_16,'YYYYDDD') ELSE NULL END,
              17,CASE WHEN SUBSTR(T1.Date_17,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_17,'YYYYDDD') ELSE NULL END,
              18,CASE WHEN SUBSTR(T1.Date_18,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_18,'YYYYDDD') ELSE NULL END,
              19,CASE WHEN SUBSTR(T1.Date_19,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_19,'YYYYDDD') ELSE NULL END,
              20,CASE WHEN SUBSTR(T1.Date_20,5) BETWEEN '001' AND '366'
                   THEN TO_DATE(T1.Date_20,'YYYYDDD') ELSE NULL END)
    Date from Table_1 t1,(select level R from dual connect by level <= 20)
    where decode ( r,
              1,Col_1,
              2,Col_2,
              3,Col_3,
              4,Col_4,
              5,Col_5,
              6,Col_6,
              7,Col_7,
              8,Col_8,
              9,Col_9,
              10,Col_10,
              11,Col_11,
              12,Col_12,
              13,Col_13,
              14,Col_14,
              15,Col_15,
              16,Col_16,
              17,Col_17,
              18,Col_18,
              19,Col_19,
              20,Col_20) !=0
    thanks
    Edited by: user627047 on Jun 23, 2009 12:07 AM

    Here I managed to get the output
    PLAN_TABLE_OUTPUT
    Plan hash value: 2442671038
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 408 | 274K| 40 (43)| 00:00:01 |
    | 1 | NESTED LOOPS | | 408 | 274K| 40 (43)| 00:00:01 |
    | 2 | VIEW | | 1 | 13 | 2 (0)| 00:00:01 |
    |* 3 | CONNECT BY WITHOUT FILTERING| | | | | |
    | 4 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
    |* 5 | EXTERNAL TABLE ACCESS FULL | EVP0010 | 408 | 269K| 38 (45)| 00:00:01 |
    Predicate Information (identified by operation id):
    3 - filter(LEVEL<=20)
    5 - filter(DECODE("R",1,"C_LOGO_LYLTY_CARD_1",2,"C_LOGO_LYLTY_CARD_2",3,"C_LOGO
    _LYLTY_CARD_3",4,"C_LOGO_LYLTY_CARD_4",5,"C_LOGO_LYLTY_CARD_5",6,"C_LOGO_LYLTY_CAR
    D_6",7,"C_LOGO_LYLTY_CARD_7",8,"C_LOGO_LYLTY_CARD_8",9,"C_LOGO_LYLTY_CARD_9",10,"C
    _LOGO_LYLTY_CARD_10",11,"C_LOGO_LYLTY_CARD_11",12,"C_LOGO_LYLTY_CARD_12",13,"C_LOG
    O_LYLTY_CARD_13",14,"C_LOGO_LYLTY_CARD_14",15,"C_LOGO_LYLTY_CARD_15",16,"C_LOGO_LY
    LTY_CARD_16",17,"C_LOGO_LYLTY_CARD_17",18,"C_LOGO_LYLTY_CARD_18",19,"C_LOGO_LYLTY_
    CARD_19",20,"C_LOGO_LYLTY_CARD_20")<>0)
    24 rows selected.

  • Split multiple columns into rows using XML

    Hi Forum,
    I am trying to split 2 columns that each contain values separated by semicolon into single rows. The relation between the values of the two columns is that the order in the cells corresponds to each other.
    The data looks like this:
    pk    Manufacturer                partnumber
    1     Man1; Man2;Man3      PN1;PN2;PN3
    2     Man4; Man2;Man5      PN4;PN5;PN6
    The result should be:
    pk    Manufacturer     partnumber
    1       Man1                   PN1
    1       Man2                   PN2
    1       Man3                   PN3
    2       Man4                   PN4
    2       Man2                   PN5
    2       Man5                   PN6
    I am not sure how to format the XML to get a useful Basis for XML.value or XML.query
    Any ideas?
    TIA
    Alex

    Hi,
    Try like this ,
    DECLARE @tmp TABLE (pk INT,Manufacturer NVARCHAR(50),partnumber NVARCHAR(50))
    INSERT @tmp SELECT 1,'Man1; Man2;Man3','PN1;PN2;PN3'
    INSERT @tmp SELECT 2,'Man4; Man2;Man5','PN4;PN5;PN6'
    SELECT * FROM @tmp
    SELECT tmp2.pk pk,Manufacturer,partnumber FROM (
    SELECT ROW_NUMBER()OVER(ORDER BY tmp1.pk) RN,* FROM (
    SELECT pk,
    LTRIM(i.value('.','varchar(100)')) Manufacturer
    FROM ( SELECT pk, Manufacturer,
    CONVERT(XML,'<r><n>'
    + REPLACE(Manufacturer,';', '</n><n>') + '</n></r>') AS X
    FROM @Tmp) Spt
    CROSS APPLY Spt.X.nodes('//*[text()]') x(i)
    ) tmp1 ) tmp2
    JOIN
    (SELECT ROW_NUMBER()OVER(ORDER BY pk) RN,* FROM (
    SELECT pk,
    j.value('.','varchar(100)') partnumber
    FROM ( SELECT pk, partnumber,
    CONVERT(XML,'<r><n>'
    + REPLACE(partnumber,';', '</n><n>') + '</n></r>') AS Y
    FROM @Tmp) Spt
    CROSS APPLY Spt.Y.nodes('//*[text()]') y(j)) tmp2 ) tmp3 ON tmp3.RN = tmp2.RN
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

Maybe you are looking for

  • Embedding SWF into HTML

    Hi. I am trying to make a SWF open a new browser window when it is clicked, acting as a Splash page that opens the main page. I want the main page to open in a new window 800 x 600 with none of the address bar, toolbars etc. I've managed this but the

  • Movement type for Delivery

    Hello For Consignment Fill Up Delivery which when created and PGI it is using a movement type 631 which is transferring goods from xxxx storage location to a unknown storage location. What I need is I need to make a change which when delivery is issu

  • My new Iphone's battery does not hold charge for long; do you have the same problem?

    Greetings, I had a new iphone 4S -  bought March 2013, died suddenly September 2013. Iphone replaced by a new one, which seemed to work fine. Suddenly, noticed three days ago that the battery does not hold, even for one day, even with very little use

  • PROBLEM IN INTERNET EXPLORER WITH THE  fileupload API

    i written a servlet to upload a file which will upload a file to a specific directory.............. this program is working with opera or Mozilla browser.......but it is not working in internet explorer 8. i can not understand what is the problem....

  • Upgrading Student Edition?

    Hey all! I have the Student & Teacher edition of CS5.5 Design. There are several new feactures in CS6 that I am really excited about, but I'm graduating in less than a week, so I won't be able to qualify to purchase the S&T edition of CS6 when it com