可以用exists测试有没有数据,比count(*)效率高

解决方案 »

  1.   

    SELECT TOP 100 Percent sysobjects.name,sysindexes.rows FROM sysindexes with(nolock)
    JOIN sysobjects with(nolock) ON sysindexes.id = sysobjects.id AND sysobjects.xtype = 'u' 
    WHERE sysindexes.indid in(0, 1) ORDER By sysobjects.name ASC
      

  2.   

    太好了,谢谢hudan(中文昵称) ( )
      

  3.   

    以上代码是收藏,原帖位置:
    http://community.csdn.net/Expert/topic/3124/3124563.xml?temp=.1386072
      

  4.   

    学习楼上的
    ----使用动态sql也可以的
    spool  path/filename
    select 'select count(*) from '||table_name||';' from all_tables;
    spool off
    start filename