Remove all spaces from a string in SQL Server

后端 未结 23 908
死守一世寂寞
死守一世寂寞 2020-11-28 01:42

What is the best way to remove all spaces from a string in SQL Server 2008?

LTRIM(RTRIM(\' a b \')) would remove all spaces at the right and left of th

23条回答
  •  生来不讨喜
    2020-11-28 01:57

    To make all of the answers above complete, there are additional posts on StackOverflow on how to deal with ALL whitespace characters (see https://en.wikipedia.org/wiki/Whitespace_character for a full list of these characters):

    • TSQL 2008 Using LTrim(RTrim and still have spaces in the data
    • How do I remove non-breaking spaces from a column in SQL server?
    • What's a good way to trim all whitespace characters from a string in T-SQL without UDF and without CLR?

提交回复
热议问题