我用的是sql 2000  建立一张表 但是不知道系统把这张表建立在那个地方 系统也没有提示保存信息 

解决方案 »

  1.   

    declare @tbname sysname
    set @tbname='tb' --要查询的表名
    declare @dbname sysname,@sql nvarchar(4000),@re bit,@SQL1 varchar(8000)
    set @SQL1=''
    declare tb cursor for select name from master..sysdatabases
    open tb 
    fetch next from tb into @dbname
    while @@fetch_status=0
    begin
     set @SQL='set @re=case when exists(select 1 from ['
      +@dbname+']..sysobjects where xtype=''U'' and name='''
      +@tbname+''') then 1 else 0 end'
     exec sp_executesql @SQL,N'@re bit out',@re out
     if @re=1 set @sql1=@SQL1+' union all select '''+@dbname+''''
     fetch next from tb into @dbname
    end
    close tb
    deallocate tb
    set @sql1=substring(@SQL1,12,8000)
    exec(@SQL1)