Home Forums SQL Server 2005 T-SQL (SS2K5) ANYTHING THAT CAN HELP TRIM THE DATA FOR A GIVEN STRING... RE: ANYTHING THAT CAN HELP TRIM THE DATA FOR A GIVEN STRING...

  • A nonelegant way to do this is to use a series of replace statements that make a set of 4 spaces 1 space, then 3 spaces 1 space, then 2 spaces 1 space.

    replace(string, ' ',' ')

    replace(string, ' ',' ')

    replace(string, ' ',' ')

    Alternatively, loop through a replace two space command until there's not any more spaces longer than one character.

    I've done something similar in MS Word and in Notepad. I've probably done it in Query Analyzer as well.