开发者

Search List of Strings For String Match

I am trying to create a SQL trigger that will alert me when a user types in certain words. I have it working with a single word but I need to get this working with a list of words. How can I get something similar to the following, that will search a list of words stored in some other location.

WHERE CHARINDEX('BadWord',Body) > 开发者_运维百科0


Join with a BadWords table and compare to the entries in that list in your trigger:

select
    *
from
    inserted i, badwords b
where
    charindex(b.badword, i.Body) > 0


Join onto a bad word table

select
    *
from
    INSERTED I
    JOIN
    myBadWords B ON I.Body LIKE '%' + b.badword + '%'

This won't run well though because of the leading %. Full Text Search would be better

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜