And more...
with this 3 statements below I got 3 kind of numbers (I don't mean Kb vs Mb)
The first has always [LOG File(s) Size (KB)] more big of others...
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 not in ('_Total','mssqlsystemresource')
) 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
WHERE instance_name = 'XXXX'
GO
DBCC SQLPERF(LOGSPACE);
GO
SELECT
DB_NAME(database_id) AS 'Database',
(total_log_size_in_bytes) * 1.0 / 1024 / 1024 AS 'Log file size (MB)',
(used_log_space_in_bytes) * 1.0 / 1024 / 1024 AS 'Used log space (MB)',
(total_log_size_in_bytes - used_log_space_in_bytes) * 1.0 / 1024 / 1024 AS 'Free log space (MB)'
FROM sys.dm_db_log_space_usage;
GO
In conclusion, for the purpose of a report which is better to rely on? I was using the performace counters, but it seems to be the most incorrect in size.
ALEN