if object_id('ta')is not null drop table ta go create table ta (ID int identity(1,1),content varchar(15))--脏字表 insert ta(content) select 'Fuck' insert ta(content) select 'SB' insert ta(content) select '操你' insert ta(content) select '日' if object_id('tb')is not null drop table tb go create table tb (ID int identity(1,1),content varchar(15))--正常表 declare @str varchar(20) declare @str2 varchar(20) set @str2='你好' set @str='Fuck you' insert tb(content) select @str where not exists(select 1 from ta a where charindex(''+a.content+'',@str)>0 ) insert tb(content) select @str2 where not exists(select 1 from ta a where charindex(''+a.content+'',@str2)>0 ) select * from tb /* ID content ----------- --------------- 1 你好 */
declare @str Nvarchar(4000) set @str=',Fuck,SB,' --select * from guolv where charindex(','+content+',',','+@str+',')>0select * from biao where charindex(content,@str)>0
charindex(',sb,' , ','+col+',') > 0
go
create table ta (ID int identity(1,1),content varchar(15))--脏字表
insert ta(content) select 'Fuck'
insert ta(content) select 'SB'
insert ta(content) select '操你'
insert ta(content) select '日'
if object_id('tb')is not null drop table tb
go
create table tb (ID int identity(1,1),content varchar(15))--正常表
declare @str varchar(20)
declare @str2 varchar(20)
set @str2='你好'
set @str='Fuck you'
insert tb(content) select @str where not exists(select 1 from ta a where charindex(''+a.content+'',@str)>0 )
insert tb(content) select @str2 where not exists(select 1 from ta a where charindex(''+a.content+'',@str2)>0 )
select * from tb
/*
ID content
----------- ---------------
1 你好
*/
set @str=',Fuck,SB,'
--select * from guolv where charindex(','+content+',',','+@str+',')>0select * from biao where charindex(content,@str)>0