Removing whitespace - three variables RRS feed

  • Question

  • Hello

    As part of a report I am required to removed whitespace from text.

    The report output is currently appearing as either:

    AB9 ZZZ                                                     
    AB99 ZZZ                                                   


    where I need the output to be:

    AB9ZZZ   or


    However there are some instances where the output has no whitespace - and appears as AB9ZZZ, for example, or AB99ZZZ - and I wish that to be left alone.

    I've had a go with TRIM but am not really getting anywhere - please can you advise?

    Wednesday, January 8, 2020 3:21 PM


    create table test (col varchar(200))
    insert into test values 
    ('AB99 ZZZ')
    ,('AB9 ZZZ'),('AB9ZZZ')
    select col, replace(col,' ','')  
    from  test
    drop table test

    Wednesday, January 8, 2020 3:30 PM

All replies