Insert space char into results
Insert space char into results
(OP)
Hi guys,
I am trying to find a way to insert a space to seperate the first name and last name in my column when I query the db,
currently my data is displayed this way:
Abauer
Jjones
Asmith
and I would like it this way:
A Bauer
J Jones
A Smith
Is it possible to execute this in a query.
I am trying to find a way to insert a space to seperate the first name and last name in my column when I query the db,
currently my data is displayed this way:
Abauer
Jjones
Asmith
and I would like it this way:
A Bauer
J Jones
A Smith
Is it possible to execute this in a query.
RE: Insert space char into results
For example this works for me on DB2 UDB
CODE
select 'Abauer'
from sysibm.sysdummy1 union all
select 'Jjones'
from sysibm.sysdummy1 union all
select 'Asmith'
from sysibm.sysdummy1)
select
name,
left(name,1) concat ' ' concat
upper(left(substr(name,2,length(name)-1),1)) concat
substr(name,3,length(name)-2) as name_new
from names
CODE
NAME NAME_NEW
Abauer A Bauer
Jjones J Jones
Asmith A Smith
******** End of data ********
RE: Insert space char into results
What is the SQL code ?
Hope This Helps, PH.
FAQ219-2884: How Do I Get Great Answers To my Tek-Tips Questions?
FAQ181-2886: How can I maximize my chances of getting an answer?
RE: Insert space char into results
yeah mikrom that is what I am going for but without having to manually insert the names in the query, I presume by modifying your code slightly I could achieve this.
btw guys here is my code:
CODE
SET @DateNow=convert(CHAR(10),getdate(),120)
SET @status='online'
SELECT REPLACE([ADEReport].[dbo].[User].[JID],'@bmwlds1mun.sei-it.net',' ')as Agent
,MIN(convert (varchar(10),DATEADD(Hour,2,ChangeTime),108)) as TimeLoggedIn
FROM [ADEReport].[dbo].[PresenceChange]JOIN [ADEReport].[dbo].[User]
ON [ADEReport].[dbo].[PresenceChange].[UID] = [ADEReport].[dbo].[User].[UID]
AND CONVERT(CHAR(10),ChangeTime,120) = @DateNow
AND PresenceStatus = @status
group by JID
order by JID asc";
RE: Insert space char into results
thanx for you help.
CODE