在某ntext字段中怎么查找包含某字符串的总数,不是记录条的总数

注意是数量,而不是记录。比如。myTable中Content字段为ntext类型,如果其中只有两条记录:第一条为“我是一个兵,你是一个兵”第二条:“他不是一个兵”,那么我查询content中含有”一个兵“字符串的个数应该为3,注意而不是2。如何实现,谢谢。
---------------------------------------------------------------

sleect sum(case when len(replace(content,'一个兵',''))<>Len(content) then cast((len(content)-len(replace(content,'一个兵','')))/len('一个兵') as int) else 0 end) as WhatYouWanted From myTable

Published At
Categories with 数据库类
Tagged with
comments powered by Disqus