码迷,mamicode.com
首页 > 数据库 > 详细

SQL Server统计数据库总量

时间:2020-05-25 13:54:02      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:group   https   object   property   log   nbsp   from   table   obj   

按月查看历史数据的增长


SELECT
[database_name] AS "Database",
DATEPART(month,[backup_start_date]) AS "Month",
AVG([backup_size]/1024/1024) AS "Backup Size MB"
FROM msdb.dbo.backupset
WHERE
[database_name] = N‘Adventureworks2012‘
AND [type] = ‘D‘
GROUP BY [database_name],DATEPART(mm,[backup_start_date]);

 

查询数据库总数据条数

1、

select  

        sum(c.row_count) as datacount  
from    sys.indexes a ,  
        sys.objects b ,  
        sys.dm_db_partition_stats c  
where   a.[object_id] = b.[object_id]  
        AND b.[object_id] = c.[object_id]  
        AND a.index_id = c.index_id  
        AND a.index_id < 2  

        AND b.is_ms_shipped = 0 

 

2:

select  b.name as tablename ,  
        a.rowcnt as datacount  
from    sysindexes a ,  
        sysobjects b  
where   a.id = b.id  
        and a.indid < 2  
        and objectproperty(b.id, ‘IsMSShipped‘) = 0 

SQL Server统计数据库总量

标签:group   https   object   property   log   nbsp   from   table   obj   

原文地址:https://www.cnblogs.com/wuweierzhi/p/12956452.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!