vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| I HAVE A STRING: ABCDEFG HOW TO INSERT A SPACE BETWEEN ALL CHARACTERS? REQUESTED OUTPUT: A B C D E F G Thank's in advance Leny G. -- Message posted via DBMonster.com http://www.dbmonster.com/Uwe/Forums....m-db2/200804/1 |
| |||
| Hi! If you have a fixed number of characters you can use INSERT(INSERT(INSERT(INSERT(INSERT(INSERT('ABCDEFG ',2,0,' '),4,0,' '),6,0,' '),8,0,' '),10,0,' '),12,0,' ') else you will want a stored procedure or UDF looping over the length of the string doing for instance an insert /dg "lenygold via DBMonster.com" <u41482@uwe> wrote in message news:837fb3b2f4e25@uwe... > I HAVE A STRING: ABCDEFG > > HOW TO INSERT A SPACE BETWEEN ALL CHARACTERS? > REQUESTED OUTPUT: > > A B C D E F G > > Thank's in advance Leny G. > > -- > Message posted via DBMonster.com > http://www.dbmonster.com/Uwe/Forums....m-db2/200804/1 > |
| |||
| lenygold via DBMonster.com wrote: > I HAVE A STRING: ABCDEFG > > HOW TO INSERT A SPACE BETWEEN ALL CHARACTERS? > REQUESTED OUTPUT: > > A B C D E F G > > Thank's in advance Leny G. The TRANSLATE function [1] can be handy for this: VALUES TRANSLATE('A B C D E F G H', SOMESTRING, 'ABCDEFGH') For example: SELECT TRANSLATE('A B C D E F G H', S, 'ABCDEFGH') FROM ( VALUES ('ABCD'), ('1234'), ('Testing') ) AS T(S) Outputs: 1 --------------- A B C D 1 2 3 4 T e s t i n g 3 record(s) selected. Just expand the first and third parameters with more characters if extra length is required. [1] http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l uw.sql.ref.doc/doc/r0000862.html Cheers, Dave. |
| ||||
| Thank you. Translate is working Dave Hughes wrote: >> I HAVE A STRING: ABCDEFG >> >[quoted text clipped - 4 lines] >> >> Thank's in advance Leny G. > >The TRANSLATE function [1] can be handy for this: > >VALUES TRANSLATE('A B C D E F G H', SOMESTRING, 'ABCDEFGH') > >For example: > >SELECT > TRANSLATE('A B C D E F G H', S, 'ABCDEFGH') >FROM ( > VALUES > ('ABCD'), > ('1234'), > ('Testing') > ) AS T(S) > >Outputs: > >1 >--------------- >A B C D >1 2 3 4 >T e s t i n g > > 3 record(s) selected. > >Just expand the first and third parameters with more characters if >extra length is required. > >[1] >http://publib.boulder.ibm.com/infoce.../com.ibm.db2.l >uw.sql.ref.doc/doc/r0000862.html > >Cheers, > >Dave. -- Message posted via http://www.dbmonster.com |
| Thread Tools | |
| Display Modes | |
| |