首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Sybase >

Sybase的SQL怎么去掉字符串中间的空格

2012-03-17 
Sybase的SQL如何去掉字符串中间的空格?SQL codeselect StringReplace( dfdddf dfd, ,)返回仍然是“ d

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) 

热点排行