ITPub博客

首页 > 应用开发 > IT综合 > Trim() 函数的介绍

Trim() 函数的介绍

原创 IT综合 作者:myhuaer 时间:2005-12-03 11:04:28 0 删除 编辑

Trim()
很多人对Trim()函数的用法仅仅限于去掉两边空格。下面让大家看看Trim()到底能帮我们作些什么/

TRIM 可以去掉字符串中开头或结尾(或全部)的字符的某个字符。必须要将去掉的字符放在'' 之间。
如果不写某些字符则会字符串两边的空格(space) 去掉。


INSERT into demo values('weather',1,'lis',N'天气')
insert into demo values('waiwai',1,'lis',N'外外')
insert into demo values('waiwai11w',1,'lis',N'外外')

select name,trim(leading 'w' from name) for_test from demo
"NAME" "FOR_TEST"
"wether" "ether"
"waiwai11w" "aiwai11w"
"weather" "eather"


select name,trim(TRAILING 'w' from name) for_test from demo
"NAME" "FOR_TEST"
"wether" "wether"
"waiwai" "waiwai"
"waiwai11w" "waiwai11"
"weather" "weather"

select name,trim(both 'w' from name) for_test from demo

"NAME" "FOR_TEST"
"wether" "ether"
"waiwai" "aiwai"
"waiwai11w" "aiwai11"
"weather" "eather"

select name ,trim(name) for_test from demo
"NAME" "FOR_TEST"
"wether" "wether"
"waiwai" "waiwai"
"waiwai11w" "waiwai11w"
"weather" "weather"

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/34596/viewspace-811148/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2016-09-11

  • 博文量
    211
  • 访问量
    634623