Listarea memoriei consumate de fiecare baza de pe un server MSSQL

Configurare noua (How To)

Situatie

Mai jos este o procedura ce returneaza pentru fiecare baza de date de pe ms sql server, dimensiunea memoriei consumate de acea baza.

Solutie

— exec DbRamConsumption_prc @dbname = ”

 

 

create procedure DbRamConsumption_prc
@dbname varchar(128) = ”
as
begin

 

set @dbname = nullif(@dbname,”)

;with getdblist
as
(
select
isnull(db_name(database_id), ‘resourcedb’) [dbname]
, cast(count(row_count)/128.0 as decimal(10,2)) [size]
from sys.dm_os_buffer_descriptors
group by database_id
)
select dbname [databasename],size [size in MB]
from getdblist
where dbname = isnull(@dbname,dbname)
order by dbname

 

end

Tip solutie

Permanent

Voteaza

(11 din 23 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?