TSQL:Бэкапы,логи,количество строк в таблицах,Количество прочтений\записей
--Бэкапы баз данных и их расположение
USE master;
SELECT
d.Name,
b.Backup_finish_date,
bmf.Physical_Device_name
FROM
sys.databases d
INNER JOIN msdb..backupset b
ON
b.database_name = d.name
INNER JOIN msdb.dbo.backupmediafamily bmf
ON
b.media_set_id = bmf.media_set_id
ORDER BY d.NAME, b.Backup_finish_date DESC;
--Количество строк по индексам
USE msdb;
SELECT
DB_NAME() +'.'+
OBJECT_SCHEMA_NAME(p.object_id) +'.'+
OBJECT_NAME(p.object_id) AS [Table],
i.Type_Desc ,
i.Name AS [Index],
SUM(p.Rows) AS [Rows]
FROM
sys.partitions p
JOIN sys.indexes i
ON i.object_id = p.object_id AND i.index_id = p.index_id
WHERE
i.type_desc IN ( 'CLUSTERED', 'HEAP' ) AND OBJECT_SCHEMA_NAME(p.object_id) <> 'sys'
GROUP BY p.object_id, i.type_desc, i.Name
ORDER BY [Table];
--Количество прочтений\записей с момента последней перезагрузки (только по таблицам с индексами)
SELECT
DB_NAME() +'.'+
OBJECT_SCHEMA_NAME(ddius.object_id) +'.'+
OBJECT_NAME(ddius.object_id) AS [Table],
SUM(ddius.user_seeks + ddius.user_scans + ddius.user_lookups)
AS Reads ,
SUM(ddius.user_updates) AS Writes ,
SUM(ddius.user_seeks + ddius.user_scans + ddius.user_lookups
+ ddius.user_updates) AS [Reads&Writes] ,
( SELECT DATEDIFF(s, create_date, GETDATE()) / 86400.0
FROM master.sys.databases
WHERE name = 'tempdb'
) AS [Days],
( SELECT DATEDIFF(s, create_date, GETDATE()) AS SecoundsRunnig
FROM master.sys.databases
WHERE name = 'tempdb'
) AS [Seconds]
FROM sys.dm_db_index_usage_stats ddius
INNER JOIN sys.indexes i ON ddius.object_id = i.object_id
AND i.index_id = ddius.index_id
WHERE OBJECTPROPERTY(ddius.object_id, 'IsUserTable') = 1
AND ddius.database_id = DB_ID()
GROUP BY OBJECT_NAME(ddius.object_id), OBJECT_SCHEMA_NAME(ddius.object_id)
ORDER BY [Reads&Writes] DESC;