--结果不准确,接近 select rows from sysindexes where id = object_id('ABC') and indid in (0,1)--or 准确 select count(1) from ABC
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
从statictics中取快 但滞后 count计算慢但精确
--优点:速度快 --缺点:表里有10000条数据,返回的结果可能是9999或10001或其它 select rows from sysindexes where id = object_id('ABC') and indid in(0,1)--优点:准确 --缺点:速度慢 select count(1) from ABC
select rows from sysindexes where id = object_id('ABC') and indid in (0,1)--or 准确
select count(1) from ABC
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
--缺点:表里有10000条数据,返回的结果可能是9999或10001或其它
select rows from sysindexes where id = object_id('ABC') and indid in(0,1)--优点:准确
--缺点:速度慢
select count(1) from ABC
gosp_spaceused 'ABC'