如果我要判断一个表的记录数有多少条,怎么判断??????这个问题吗???????很简单
一般表里面都有id的select max(id) from 表这样就可以了

解决方案 »

  1.   

    --结果不准确,接近
    select       rows       from       sysindexes       where       id       =       object_id('ABC')       and       indid       in       (0,1)--or 准确 
    select count(1) from ABC
      

  2.   


    create proc p_checkNum 
    as   
      if exists (select 1 from sysobjects where name = 'ABC')
      begin
        if (Select count(*) from ABC) = 100000 --统计记录数
        begin
          backup database 数据库 to disk='c:\11.bak' 
        end
      end
      

  3.   

    从statictics中取快 但滞后 count计算慢但精确
      

  4.   

    --优点:速度快
    --缺点:表里有10000条数据,返回的结果可能是9999或10001或其它
    select rows from sysindexes where id = object_id('ABC') and indid in(0,1)--优点:准确
    --缺点:速度慢 
    select count(1) from ABC
      

  5.   

    DBCC UPDATEUSAGE (0)
    gosp_spaceused 'ABC'