Results 1 to 3 of 3

Thread: Modified

  1. #1
    Join Date
    Aug 2003
    Location
    Pune
    Posts
    38

    Modified

    we have a table structure like this

    name code

    a xYZ | MNO
    b XYZ | MNO



    i want an output like this

    name code

    a XYZ
    a MNO
    b XYZ
    b MNO

    how to achieve this in SQL Server 2000

  2. #2
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    use tempdb


    create table x124 (name varchar(10), code varchar(100))
    insert into x124 select 'a', 'xYZ | MNO'
    insert into x124 select 'b', 'XYZ | MNO'

    select name, left(code,charindex('|',code,1)) as Code
    from x124
    union
    select name, right(code,len(code)-charindex('|',code,1)-1) as Code
    from x124

  3. #3
    Join Date
    Aug 2003
    Location
    Pune
    Posts
    38

    s'ry

    thx for u r answer
    but i'm sorry for posting the half part of my requirement

    we have a table structure like this

    name code

    a XYZ | MNO
    b XYZ | MNO | PQR
    c XYZ



    i want an output like this

    name code

    a XYZ
    a MNO
    b XYZ
    b MNO
    b PQR
    c XYZ

    in the code column,there may be n number of items seprated by |

    thanks once again
    PL'z help me

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •