Sql 计算一个词出现的次数

create table w
(
word nvarchar(100)
)

insert into w(word)
select('去')
union all
select('第三方')
union all
select(',')
union all
select('士大夫')
union all
select('girls')
union all
select(' <:')

declare @t nvarchar(1000)
set @t='我们今天要去的地方要和第三方枯叶,顶替顶替去要夺枯地枯需要地 <.'

select word,(len(@t)-len(replace(@t,word,'')))/len(word)
from w
where @t like '%'+word+'%'

posted @ 2012-06-04 16:00  浪潮  阅读(510)  评论(0编辑  收藏  举报