How do you take out extra spaces in query

Hello I have a problem how do i delete any blank spaces
 5185  INTERNAL AUDITING             .(--this is where this blank space stops)
I only want one space in between each space and it adds 5 to 6 spaces in the front or in the back of each query some titles are longer than others but i dont know why its doing this. I am also putting 2 tables into 1 I am combining the call center and the name of department together
dbo.AS400_CEmployee.Department + ' ' + CAST(dbo.AS400_CEmployee.Department_Desc AS varchar(40)) AS department

Open in new window

Who is Participating?
Patrick MatthewsConnect With a Mentor Commented:
LTRIM(RTRIM(dbo.AS400_CEmployee.Department + ' ' + CAST(dbo.AS400_CEmployee.Department_Desc AS varchar(40)))) AS department
jbulldozaConnect With a Mentor Commented:
Try using rtrim -

rtrim(dbo.AS400_CEmployee.Department) + ' ' + rtrim(CAST(dbo.AS400_CEmployee.Department_Desc AS varchar(40)) AS department)
kuintencstAuthor Commented:
Thank you both worked like a charm
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.