Cele mai utilizate baze de pe un server MSSQL

Configurare noua (How To)

Situatie

Mai jos este un select ce returneaza bazele de pe un server MSSQL in functie de gradul de utilizare a lor, de la cea mai utilizata la cea mai putin utilizata.

Solutie

SELECT DB_NAME(CAST(attributes.value AS INT)) AS DatabaseName
, SUM(total_elapsed_time) AS ElapsedTime
, SUM(total_worker_time) AS WorkerTime
, SUM(total_logical_reads) AS LogicalReads
, SUM(total_physical_reads) AS PhysicalReads
, SUM(total_logical_writes) AS Writes
FROM sys.dm_exec_query_stats stats
CROSS APPLY sys.dm_exec_plan_attributes (plan_handle) attributes
WHERE attributes.attribute = ‘dbid’ and DB_NAME(CAST(attributes.value AS INT)) is not null
GROUP BY attributes.value
ORDER BY 2 DESC

Tip solutie

Permanent

Voteaza

(2 din 2 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?