data in one column should go into two columns

  • data:

    e_id ename

    1 abc xyz def

    2 ghi jqk

    o/p:

    e_id firstname middlename lastname

    1 abc xyz def

    2 ghi jqk

  • Use Substring and charindex for ' ' character and split the string into three.

  • krishnachowdary8 (7/19/2011)


    data:

    e_id ename

    1 abc xyz def

    2 ghi jqk

    o/p:

    e_id firstname middlename lastname

    1 abc xyz def

    2 ghi jqk

    Hi krishnachowdary8, This question looks a little like a homework problem...which is fine as long as there is an attempt on your part to do the work. I will be happy to assist you, I only ask that you provide a few things to help get started.

    Please provide:

    1. your CREATE TABLE statement

    2. some INSERT INTO statements to generate the sample data in your post

    3. the query or queries you have tried so far (most important!)

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Ya I got it

    substr(NAME,0,instr(NAME,' '))

    substr(NAME,instr(NAME,' '),instr(NAME,' ',1,2)-instr(NAME,' ')

    substr(ename,1,instr(ename,' '))

    Thank You

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply