阅读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 硬盘相关知识