Tuesday, February 26, 2013

Split the String into columns

If you have string coming from your database which has separated by some special character and you want to split that string into multiple columns, follow the below technique.

For example  one of the value from the string is 'The;Name;is;Kishore;Dirisala'  and the name of the data item is [Full]

Full :'The;Name/is;Kishore;Dirisala' 


1 : substring([Full], 1, position('/',[Full] )-1) 
A : substring( [Full], position( '/', [Full] )+1) 
2 : substring([A],1,position('/',[A] )-1) 
B : substring( [A], position( '/', [A] )+1) 
3 : substring([B],1,position('/',[B] )-1) 
C : substring( [B], position( '/', [B] )+1) 
4 : substring([C],1,position('/',[C] )-1) 
D : ubstring( [C], position( '/', [C] )+1) 
5 : substring([D],1,position('/',[D] )-1) 

Then bring then into a list object. A,B,C,D and E should give you what you 
want. 


The Final out put will be like below

1: The
2: Name
3:  is
4: Kishore
5: Dirisala


                                                                                                                                          ---Enjoy

1 comment:

  1. Thanks !! One correction :

    Then bring then into a list object. 1,2,3,4 and 5 should give you what you
    want.

    Bhanwar Gupta
    http://www.bhanwar.com

    ReplyDelete