SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


missing concatenated star


missing concatenated star

Author
Message
rot-717018
rot-717018
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1246 Visits: 504
Hi all,
I have got something weird, I've never seen before.

Running the query ...
select ccc_id, town, '*' + rtrim(TOWN) + '*', *
from CLI_CONTACTS
where CLC_ID = '244_'

returns following dataset

ccc_id town (No column name)
3802 Berlin *Berlin*
26880 Berlin *Berlin
40921 Berlin *Berlin*
41547 Berlin *Berlin*
65604 Berlin *Berlin*

Why is the trailing star missing on the second line?
Any suggestion will be much appreciated.
Thanks
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96366 Visits: 21215
rot-717018 - Tuesday, March 28, 2017 7:32 AM
Hi all,
I have got something weird, I've never seen before.

Running the query ...
select ccc_id, town, '*' + rtrim(TOWN) + '*', *
from CLI_CONTACTS
where CLC_ID = '244_'

returns following dataset

ccc_id town (No column name)
3802 Berlin *Berlin*
26880 Berlin *Berlin
40921 Berlin *Berlin*
41547 Berlin *Berlin*
65604 Berlin *Berlin*

Why is the trailing star missing on the second line?
Any suggestion will be much appreciated.
Thanks


Are you sure that you don't have some kind of blank space different to the normal space? Possibilities are tabs, line feeds, hard spaces, etc.

What's the result of this query?

WITH
E(n) AS(
SELECT n FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0))E(n)
),
E2(n) AS(
SELECT a.n FROM E a, E b
),
E4(n) AS(
SELECT a.n FROM E2 a, E2 b
),
cteTally(n) AS(
SELECT ROW_NUMBER() OVER(ORDER BY (SELECT NULL)) n
FROM E4
)
SELECT SUBSTRING( town, n, 1), ASCII(SUBSTRING( town, n, 1))
FROM CLI_CONTACTS c
JOIN cteTally t ON LEN(c.town) >= t.n
where CLC_ID = '244_'
AND ccc_id = 26880;



Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
rot-717018
rot-717018
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1246 Visits: 504
Thanks Luis!
I did not know/remember about the ASCII function.
The result is
3802 Berlin 105
3802 Berlin 110
26880 Berlin 66
26880 Berlin 101
26880 Berlin 114
26880 Berlin 108
26880 Berlin 105
26880 Berlin 110
26880 Berlin 0
40921 Berlin 66
40921 Berlin 101
40921 Berlin 114
40921 Berlin 108
Now I need to find out how to replace this 0 with a blank ...
rot-717018
rot-717018
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1246 Visits: 504
GOT IT !

If I run following query, it's all fine ...

select ccc_id, town, '*' + rtrim(TOWN) + '*',

'*' + replace(rtrim(town), char(0), '') + '*'

from CLI_CONTACT_CHANGES

where FK_CLIENT_CONTACLC_ID = '244_CORRESP'


Thanks a lot Luis for your help!!! Problem quiclkly solved Smile
Luis Cazares
Luis Cazares
SSC Guru
SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)SSC Guru (96K reputation)

Group: General Forum Members
Points: 96366 Visits: 21215
I'm glad that you were able to solve your problem.


Luis C.
General Disclaimer:
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?


How to post data/code on a forum to get the best help: Option 1 / Option 2
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search