sqlserver 去除空格

来源:互联网 发布:交友app源码多少钱 编辑:程序博客网 时间:2024/04/29 13:54

SQLService 中使用ltrim()去除左边空格,

rtrim()去除右边空格,

没有同时去除左右空格的函数,要去除所有空格可以用replace(字符串,' ',''),将字符串里的空格替换为空。

例:去除空格函数。

declare @temp char(50)
set @temp = ' hello 123'

print ltrim(@temp) --去除左边空格
print rtrim(@temp) --去除右边空格
print replace(@temp,' ','') --去除字符串里所有空格
print @temp

>> 输出结果

hello 123
hello 123
hello123
hello 123
原创粉丝点击