select num=len(NTEXT字段)-len(replace(NTEXT字段,'a','')) from tb

解决方案 »

  1.   

    楼上两位的思路很好,可是len好像不支持NTEXT类型阿
      

  2.   

    的确,text太多的不方便。
    我都是用程序处理的
      

  3.   

    len 和 replace 都不支持 blob(image ,text) 类型的编程使用 blob 类型的 readtext 来读取块数据
    datalength 获取 blob 类型的长度下面是个大概的流程,具体查书delcare @textptr binary(16)    --blob 类型转换
    delcare @textsize int          --blob 类型每次读取的块数据长度
    delcare @textindex int         --blob 类型每次读取的index 位置begin tran
    select @textptr = textptr (blob 类型字段),@textsize  ,@textindex 
    from table(holdlock)        -- 注意holdlockwhile 循环   -- 当前 index < datalength(blob 类型字段)
         begin
              readtext  --读取块数据
              --开始处理
              select @textsize  ,@textindex   --重新设置读取长度和index
         endcommit tran1.注意最后一次读取的块长度,否则出错
    2.中文问题,每次读取出来的中文如果编码错位,则中文出现乱码,那么中间处理的比较也会出错此问题尤其注意