• ntext replace sql


    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        
  • 相关阅读:
    小程序 图片和文字放在一行对齐的方法
    Linux下Redis安装使用教程
    关系型数据库和非关系型数据库的区别
    微信小程序scroll-view 横向和纵向scroll-view组件
    ThinkPHP5.0手把手实现手机阿里云短信验证
    极验(Geetest) Laravel 5 集成开发包,让验证更安全
    (进阶篇)PHP(thinkphp5框架)实现用户注册后邮箱验证,激活帐号
    详解PhpSpreadsheet设置单元格
    使用PhpSpreadsheet将Excel导入到MySQL数据库
    【JZOJ4783】【NOIP2016提高A组模拟9.15】Osu
  • 原文地址:https://www.cnblogs.com/flyfish/p/1444877.html
Copyright © 2020-2023  润新知