Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

odd characters inserted at end of string during sql server update

Avatar of PeterBaileyUk
PeterBaileyUk asked on
Microsoft SQL Server
14 Comments1 Solution117 ViewsLast Modified:
I have this query, it was part of another ee question but I cannot find the id now.

the query is working but ive spotted some odd additions at the end of the string output which shouldnt be there

the query is below. ive highlighted the attachment to show whats added

ive attached an xml output, i suspect its that space at the end causing this, can i get rid of that during the update sql, if indeed thats what it is.

<TblWords ClientCodeWordPosition="07130219__5" StrFull="320 D GT LUXURY " StrShort="320 D GT LUXURY &amp;#x20;" />
<TblWords ClientCodeWordPosition="07130219_320_1" StrFull="320 D GT LUXURY " StrShort="320 D GT LUXURY &amp;#x20;" />
<TblWords ClientCodeWordPosition="07130219_D_2" StrFull="320 D GT LUXURY " StrShort="320 D GT LUXURY &amp;#x20;" />
<TblWords ClientCodeWordPosition="07130219_GT_3" StrFull="320 D GT LUXURY " StrShort="320 D GT LUXURY &amp;#x20;" />
<TblWords ClientCodeWordPosition="07130219_LUXURY_4" StrFull="320 D GT LUXURY " StrShort="320 D GT LUXURY &amp;#x20;" />

use Dictionary

WITH Filtered
AS ( SELECT W.Word, w.WordPosition, w.clientcode, w.ClientCodeWordPosition, w.StrShort
    FROM tblwords w
		LEFT JOIN tblwordtags wt ON W.clientcodeWordPosition = wt.clientcodeWordPosition
    WHERE wt.word IS NULL)

UPDATE tblwords
SET StrShort = RTRIM((SELECT I.Word + ' '
			FROM Filtered I
			WHERE I.clientcode = tblwords.clientcode
			ORDER BY i.WordPosition

			FOR XML PATH('')))
Avatar of Vitor Montalvão
Vitor MontalvãoFlag of Switzerland imageIT Engineer
This problem has been solved!
Unlock 1 Answer and 14 Comments.
See Answers