Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > IBM DB2 > Re: Space betwe...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 4 Topic 8844 of 9366
Post > Topic >>

Re: Space between characters

by "Dave Hughes" <dave@[EMAIL PROTECTED] > May 1, 2008 at 08:23 AM

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/infocenter/db2luw/v9r5/topic/com.ibm.db2.l
uw.sql.ref.doc/doc/r0000862.html


Cheers,

Dave.
 




 4 Posts in Topic:
Space between characters
"lenygold via DBMons  2008-05-01 11:46:47 
Re: Space between characters
"Dan van Ginhoven&qu  2008-05-01 13:08:16 
Re: Space between characters
"Dave Hughes" &  2008-05-01 08:23:26 
Re: Space between characters
"lenygold via DBMons  2008-05-01 14:00:11 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 21:13:10 CDT 2008.