閱讀353 返回首頁    go 阿裏雲 go 技術社區[雲棲]


SQL 字符串去除空格函數

SQL 中使用ltrim()去除左邊空格rtrim()去除右邊空格沒有同時去除左右空格的函數,要去除所有空格可以用replace(字符串,' ',''),將字符串裏的空格替換為空 。 例:去除空格函數。
declare @temp char(50)
set @temp = ' hello sql '
print ltrim(@temp)     --去除左邊空格
print rtrim(@temp)     --去除右邊空格
print replace(@temp,' ','') --去除字符串裏所有空格
print @temp

>> 輸出結果
hello sql
 hello sql
hellosql
 hello sql

最後更新:2017-04-02 06:51:32

  上一篇:go 在Linux係統中存儲設備的兩種表示方法
  下一篇:go Linux 硬盤相關知識