473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Space between characters

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

Jun 27 '08 #1
3 1708
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@uwewrote 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

Jun 27 '08 #2
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.
Jun 27 '08 #3
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

Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: lawrence | last post by:
I'm bad at regular expressions. Is this how I would look for any set of characters that go more than 60 characters without a white space? ..{60} Also, does this match a block of PHP in an...
7
by: ms_chika | last post by:
hi to all! I just want to ask if how could i validate a text or string if it has a space between characters? Thanks in advance. *** Sent via Developersdex http://www.developersdex.com ***...
28
by: Andreas Prilop | last post by:
Jukka reports on http://www.cs.tut.fi/~jkorpela/chars/spaces.html that Internet Explorer 6 fails on the "zero width space" U+200B ​ Is this observation still valid? For which versions of MS...
38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
11
by: kenneth | last post by:
I just ran across this. #1 <DBColumn> 1 </DBColumn> #2 <DBColumn> </DBColumn> The data for #1 will be parsed and returned as " 1 ". I get a sequence of...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
2
by: panorris | last post by:
I am an infrequent user of Access and have a problem which I hope someone may be able to help me with. I have a text field in a database which contains UK postcodes similar to EH4 7TY or DN10 9IU....
17
by: JC | last post by:
sorry . i got one more problem i got a string with 4 char. i want to put that in a string with 26 char. how can i fill space on the remain char.. ?? is that i need to do a while loop do fill the...
5
by: Stu Carter | last post by:
Hi, ENV: Windows 2003 Server SP1 (+all updates), VS 2003, .Net 1.1 SP1 We've got an ASP.Net web application using State Service. All is fine until we tried to use the app through a virtual...
13
by: Bryan Parkoff | last post by:
I have seen that C/C++ Compiler supports long filename up to 254 characters plus the extension. Can header files and source code files accept space between alphabet character and numeric...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.