select a.name 
from sysindexes b,sysobjects a 
where a.type='u' and a.id=b.id and  b.rows=0

解决方案 »

  1.   

    sorry 我写错了 不要意思。
      

  2.   

    create proc get_all_null_table
    as
    begin
    declare @tb table(name  varchar(255))declare @tbname varchar(255)
    declare @m int 
    declare @sql Nvarchar(300)
    declare cr cursor for select name from sysobjects where type='u'
    set nocount on
    open cr
    fetch next from cr into @tbname
    while @@fetch_status =0
    begin
    set @sql='select @m=count(*) from '+@tbname
    exec sp_executesql @sql,N'@m int output',@m output
    if @m=0 
    begin
    insert into @tb values(@tbname)
    end 
    fetch next from cr into @tbname
    end
    close cr
    deallocate cr
    set nocount off
    select * from @tb
    end
      

  3.   

    sp_msforeachtable 'select count(*),''?'' from ? having count(*) = 0 '
      

  4.   

    select distinct a.name 
    from sysindexes b,sysobjects a 
    where a.type='u' and a.id=b.id and  b.rowcnt=0 and b.indid < 2
      

  5.   

    sp_msforeachtable 'select ''?'' from ? having count(*) = 0 '