日期:2014-05-18 浏览次数:20713 次
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,''))
from w WHERE LEN(@T)-LEN(REPLACE(@T,WORD,'')) >0
DROP TABLE W
/*
去 2
第三方 3
, 1
*/
------解决方案--------------------
--是次数啊,SORRY,这次应该对了
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 LEN(@T)-LEN(REPLACE(@T,WORD,'')) >0
DROP TABLE W
/*
去 2
第三方 1
, 1
*/
------解决方案--------------------
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+'%'
--结果
word
---------------------------------------------------------------- -----------
去 2
第三方 1
, 1
(3 行受影响)
------解决方案--------------------
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 *,(len(@t)-len(replace(@t,word,'')))/len(word)
from w where @T like '%'+word+'%'
------解决方案--------------------
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+'%'
------解决方案--------------------
我顶,看看有灭有分^_^
------解决方案--------------------