How do you take out extra spaces in query

Posted on 2008-11-07
Last Modified: 2012-05-05
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

Question by:kuintencst
    LVL 92

    Accepted Solution

    LTRIM(RTRIM(dbo.AS400_CEmployee.Department + ' ' + CAST(dbo.AS400_CEmployee.Department_Desc AS varchar(40)))) AS department

    Assisted Solution

    Try using rtrim -

    rtrim(dbo.AS400_CEmployee.Department) + ' ' + rtrim(CAST(dbo.AS400_CEmployee.Department_Desc AS varchar(40)) AS department)
    LVL 1

    Author Closing Comment

    Thank you both worked like a charm

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now