Sybase的SQL如何去掉字符串中间的空格?
- SQL code
select StringReplace(' dfdd df dfd',' ','')
返回仍然是“ dfdd df dfd”...貌似空格替换不走,苦闷!!
[解决办法]
用str_replace 函数
- SQL code
select str_replace(' abc bcd cde def', ' ', '');
[解决办法]
http://forums.databasejournal.com/archive/index.php/t-40207.html
Sybase doesnt have a replace cmd. you have to use a combo of charindex and stuff to replace it.
you could have the following to replace ur string.
- SQL code
declare @my_var char(25) select @my_var = 'abc|ert|rfrfrf|' while charindex('|', @my_var) > 0 begin select @my_var = stuff(@my_var, charindex('|', @my_var), 1, ';') end select @my_var
[解决办法]
Maybe you can have a try with str_replace function?
- SQL code
str_replace(strexpression1,strexpression2,strexression3)