源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

sqlServer实现去除字符串空格

  • 时间:2021-01-15 07:01 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:sqlServer实现去除字符串空格
 说起去除字符串首尾空格大家肯定第一个想到trim()函数,不过在sqlserver中是没有这个函数的,却而代之的是ltrim()和rtrim()两个函数。看到名字所有人都 知道做什么用的了,ltrim()去除字符串左边的空格,rtrim()去除字符串右边的空格,要去除首尾空格同时使用这个两个函数就好了。 测试:
select ltrim(' test ')    --去除左边的空格 
select rtrim(' test ')    --去除右边的空格 
select ltrim(rtrim(' test ')) --去除首尾空格 
结果: [img]http://files.jb51.net/file_images/article/201701/201701012031269.png[/img] [img]http://files.jb51.net/file_images/article/201701/2017010120312710.png[/img] [img]http://files.jb51.net/file_images/article/201701/2017010120312711.png[/img] 右侧的空格已经被去除了,但是在这里看不出来,把数据复制出来就能发现空格已经被去除了.
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部