Query help

  • Hi

    I have the data in my table looking like

    CCodeVcode

    030120 QV D4

    032280 QV D

    032281 QV D

    032282 QV D

    032410 QVTD

    032480 QV D4

    032670 QV D

    032682 QV D

    032684 QV D

    What i want is to insert this data in some table (say Mytable) with the condition that for every character in Vcode a new row is inserted with same CCode.

    So Mytable would look lie

    CCode Vcode

    030120 Q

    030120 V

    030120 D

    030120 4

    032280 Q

    032280 V

    ....

    ...

    Any great method to do this instead of using cursors and looping through

  • if table not already created then

    select ccode, substring(vcode,1,1) into mytable from youroriginaltable

    if you already created your destination table(mytable) then do insert into instead of select .. into..

    hope it helps

    ----------
    Ashish

  • this would simply ignore the other characters in Vcode field. While the other characters should be inserted as new row in new table (mytable).

  • then i think its already answered here..

    http://www.sqlservercentral.com/Forums/Topic969573-338-1.aspx.

    you should first search the site for your problem and if not able to see answer then only post your question...

    ----------
    Ashish

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

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