Skip to main content

Consulta de espacio ocupado de logs SQL SERVER

SQLPERF
Pese a que en SQL SERVER disponemos de funciones simples que nos devuelven información relevante sobre el uso de la base de datos, muchas veces necesitamos especificar campos específicos sobre una funcion predeterminada. En el ejemplo siguiente, se muestra la consulta equivalente a realizar una de las DMF más usadas:

DBCC sqlperf(logspace)

La consulta anterior es exactamente igual a la siguiente:
SELECT instance_name AS DatabaseName,
       [Data File(s) Size (KB)],
       [LOG File(s) Size (KB)],
       [Log File(s) Used Size (KB)],
       [Percent Log Used]
FROM
(
   SELECT *
   FROM sys.dm_os_performance_counters
   WHERE counter_name IN
   (
       'Data File(s) Size (KB)',
       'Log File(s) Size (KB)',
       'Log File(s) Used Size (KB)',
       'Percent Log Used'
   )
     AND instance_name != '_Total'
) AS Src
PIVOT
(
   MAX(cntr_value)
   FOR counter_name IN
   (
       [Data File(s) Size (KB)],
       [LOG File(s) Size (KB)],
       [Log File(s) Used Size (KB)],
       [Percent Log Used]
   )
) AS pvt

Comments

Popular posts from this blog

How to "safely" truncate history tables in Zabbix 6 before enabling timescale.

The script was tested against Zabbix 6.0 and 6.2. I'll add a proper introduction soon. If you don't fully understand every single line better don't run it in production. --RECREATING HISTORY TABLES WITH DATA. INSTEAD OF "WHERE FALSE" YOU CAN USE "WHERE CLOCK > X" IF YOU WANT TO PRESERVE SOME DATA ALTER TABLE history RENAME TO history_big; CREATE TABLE history as SELECT * FROM history_big where false; ALTER TABLE history_uint RENAME TO history_uint_big; CREATE TABLE history_uint as SELECT * FROM history_uint_big where false; ALTER TABLE history_str RENAME TO history_str_big; CREATE TABLE history_str as SELECT * FROM history_str_big where false; ALTER TABLE history_log RENAME TO history_log_big; CREATE TABLE history_log as SELECT * FROM history_log_big where false; ALTER TABLE history_text RENAME TO history_text_big; CREATE TABLE history_text as SELECT * FROM history_text_big where false; ALTER TABLE history_text RENAME TO history_text_big; CREATE TABLE...

Reconstruir contadores de rendimiento SQL Server 2005

lodctr.exe Descripción del problema Al intentar agregar items al monitor de rendimiento de windows (perfmon), relacionados con SQL Server, es decir, parámetros de instancia, memoria o uso de disco, estos no se pueden agregar, o se pueden agregar pero no muestran datos. Asimismo, cuando se intenta monitorear la base de datos desde otro servidor, a través de contadores, como por ejemplo con el servidor de monitoreo Zabbix, el host que se trata de monitorear no registra datos.