Splitting Query

  • Hi Experts,

     

    I would like to split the following string and then insert into a table.

    TransType   FlatAcct

    MSC001       7000200DIVD+1|5000300DIVD-1

    MSC002       4500100    +1|4000200    -1|4000300DIVD-1|4000400DIVD+1

     

    Output Table :

     

    TransType AcctNbr SubAcctNbr SubAcctCode DrCrInd

    MSC001    7000      200            DIVD            Cr

    MSC001    5000      300            DIVD            Dr

    MSC002    4500      100            NULL            Cr

    MSC002    4000       200           NULL            Dr

    MSC002    4000       300           DIVD            Dr 

    MSC002    4000       400           DIVD            cr

     

    Can any experts tell me how to split it ?

     

    Regards

    Karthik

     

     

     

     

     

     

    karthik

  • First, you'll need to be able to define the rules surrounding the split.  One can look at your string and your output table and guess, but it sure helps, especially since you're asking people to do your work, if you do as much of the up-front anlaysis as you can.  Second, read in BOL on string functions and try to do it yourself.  Once you've put forth a decent effort and get stuck, post your code with additional questions.  Instead of just asking for the answers, you should be making an attempt to learn how to do it yourself.  This is not a difficult solution if you put a bit of critical thinking into it.

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

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

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