select * from 表 where user+email+tel Like '%abc%'楼上有误 假如 user='xab' email='cxxx' user+email='xabcxxx' 你将把这条记录也select 出来
除了user like %% or email like %% 这已是最高效的法子了
if object_id('tempdb..#ttt') is not null drop table #ttt select * into #ttt from 表名 where 1=2 declare tb cursor local for select N'insert into #ttt select * from '+quotename(o.name) +' where ' +quotename(c.name)+' like N''%abc%''' from sysobjects o,syscolumns c,systypes t where o.name='表名' and o.id=c.id and c.xtype=t.xtype and objectproperty(o.id,N'IsUserTable')=1 and t.name like '%char' declare @s nvarchar(4000) open tb fetch tb into @s while @@fetch_status=0 begin exec(@s) fetch tb into @s end close tb deallocate tb select * from #ttt
假如 user='xab' email='cxxx'
user+email='xabcxxx'
你将把这条记录也select 出来
drop table #ttt
select * into #ttt from 表名 where 1=2
declare tb cursor local for
select N'insert into #ttt select * from '+quotename(o.name)
+' where '
+quotename(c.name)+' like N''%abc%'''
from sysobjects o,syscolumns c,systypes t
where o.name='表名' and o.id=c.id
and c.xtype=t.xtype
and objectproperty(o.id,N'IsUserTable')=1
and t.name like '%char'
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb
select * from #ttt
帮楼主顶~~~~