select * from sysobjects
where xtype = 'u'
    and [id] > 0下面自己做个循环就可以了(查找你要的字符串)找到了以后将sysobjects 的 [name]字段内容放在临时表或者Print 出来 
就可以了

解决方案 »

  1.   

    -- forgot2000(原作)
    IF EXISTS (SELECT name FROM sysobjects          WHERE name = 'searchname' AND type = 'P')   DROP PROCEDURE searchnameGocreate procedure searchname @sname varchar(10)Asbegincreate table #TableList(  tablename  char(200),  colname char(200)) declare @table varchar(200)declare @col varchar(200) set nocount ondeclare curTab scroll cursor for select name from sysobjects where xtype='u'open curTabfetch next from curTab into @tablewhile @@FETCH_STATUS=0begin  declare curCol scroll cursor for select name from syscolumns where (xtype=175 or xtype=167) and (id in (select id from sysobjects where name=@table))  open curCol  fetch next from curCol into @col  while @@FETCH_STATUS=0  begin    execute('insert into #TableList select '''+@table+''','''+@col+''' from '+@table+' where '+@col+'='''+@sname+'''')    fetch next from curCol into @col  end  close curCol  deallocate curCol  fetch next from curTab into @tableendclose curTabdeallocate curTabset nocount offselect  distinct * from #TableListdrop table #tablelist  end
      

  2.   

    exec sp_msforeachtable 'select ...... from ?'没有确定是哪个字段,怎么查?
      

  3.   

    --搜索某个字符串在那个表的那个字段中declare @str varchar(100)
    set @str='White'  --要搜索的字符串declare @s varchar(8000)
    declare tb cursor local for
    select s='if exists(select 1 from ['+b.name+'] where ['+a.name+'] like ''%'+@str+'%'')
    print ''所在的表及字段: ['+b.name+'].['+a.name+']'''
    from syscolumns a join sysobjects b on a.id=b.id
    where b.xtype='U' and a.status>=0
    and a.xusertype in(175,239,231,167)
    open tb
    fetch next from tb into @s
    while @@fetch_status=0
    begin
    exec(@s)
    fetch next from tb into @s
    end
    close tb
    deallocate tb/*--测试结果所在的表及字段: [authors].[au_lname]--*/
      

  4.   

    sp_msforeachtable 用不上
      

  5.   

    写个存储过程,查sysonjects,syscolumns
    可惜要用游标,麻烦