小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

去除字符串中連續(xù)的分割符

 zww_blog 2012-03-15

去除字符串中連續(xù)的分割符

分類: SQL函數(shù)分享系列 885人閱讀 評論(2) 收藏 舉報(bào)

--創(chuàng)建函數(shù)

create function [dbo].[m_delrepeatsplit]

(

    @str varchar(2000),

    @split nvarchar(200)

)

returns nvarchar(2000)

as  

begin

    --begin declare   

       declare @count int,@i int,@isnull int

       declare @newchar nvarchar(200),@nn nvarchar(300)

       set @count=len(@str);set @i=1;set @isnull=1;set @nn='';

    --end declare

    --begin while

       while @i<@count+1

       begin

           set @newchar=substring(@str,@i,1)

           if(@isnull=1)

           begin

              set @nn=@nn+@newchar;   

              if(@newchar=@split)

                  begin

                     set @isnull=0;

                  end

              else

                  begin

                     set @isnull=1;

                  end   

           end

           else

              begin

                  if(@newchar=@split)

                     begin

                         set @isnull=0;

                     end

                  else

                     begin

                         set @nn=@nn+@newchar;   

                         set @isnull=1;

                     end   

              end

           set @i=@i+1;

       end

    --end while

    return  @nn

end

 

--2、測試示例

declare @str nvarchar(200)

set @str='1  2 3    4 555 6  7    7';

declare @split nvarchar(200)

set @split=' ';

select dbo.m_delrepeatsplit(@str,@split) as newchar

 

--3、運(yùn)行結(jié)果

/*

newchar

------------------

1 2 3 4 555 6 7 7

*/

 

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約