create       table       test(id       int       identity(1,1),content       ntext)        
      insert       test       values(N'asdfsdfasdfsadfsdjflk大力sdjflkasjdf;lasdjf;lafsd')        
      insert       test       values(N'fdsgdsfgdfgsdfghrtjtyjkhkhjkhjljk大力ljk;jk;kl;kl;kl;')        
      go        
           
      create       proc       替换        
      @s_str       varchar(100),        
      @d_str       varchar(100)        
      as        
      declare       @id       int        
      declare       #tb       cursor       for       select       id       from       test        
      open       #tb        
      fetch       next       from       #tb       into       @id        
      while       @@fetch_status=0        
      begin        
              declare       @p       varbinary(16),@postion       int,@rplen       int        
              select       @p=textptr(CONTENT),@rplen=len(@s_str),@postion=charindex(@s_str,CONTENT)-1       from       test       where       id=@id        
              while       @postion>0        
                      begin        
                              updatetext       test.CONTENT       @p       @postion       @rplen       @d_str        
                                      select       @postion=charindex(@s_str,content)-1       from       test       where       id=@id        
                      end        
              fetch       next       from       #tb       into       @id        
      end        
      close       #tb        
      deallocate       #tb        
      go        
           
      exec       替换       '大力','AAAAA'        
           
      go        
           
      select       *       from       test        
           
      go        
      drop       table       test        

相关文章:

  • 2021-06-08
  • 2021-11-11
  • 2022-12-23
  • 2022-03-09
  • 2022-12-23
  • 2022-02-05
  • 2021-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-02
  • 2021-08-06
  • 2021-07-26
  • 2022-12-23
  • 2021-12-24
  • 2021-10-01
相关资源
相似解决方案