Copyright © 2005 - 2019 Yohz Software, a division of Yohz Ventures Sdn Bhd. ALL RIGHTS RESERVED.
All trademarks or registered trademarks are property of their respective owners
SQL Size script:
raise alert if databases’ transaction log is > 1 GB
Details:
A databases’ transaction log is used to store transactions prior to them being committed and/or backed, depending on the
databases’ recovery model. A large transaction log may indicate a long-running transaction, and/or a long overdue backup.
This script raises an alert if your databases’ transaction log is larger than 1 gigabyte. Details of the current transaction log
and database sizes are also provided.
Sample alert:
Code:
procedure Main;
var
ADatabase: TDatabase; // store a database reference
f: Integer; // loop variable
begin
for f := 0 to Instance.DatabaseCount - 1 do
begin
// get a reference to each database in the loop
ADatabase := Instance.Database(f);
if ADatabase.LogSize > (1 * GB) then
begin
RaiseAlert('Transaction log size is > 1 GB. Current size is ' +
FormatBytes(ADatabase.LogSize) + '. Database size is ' +
FormatBytes(ADatabase.Size) + '.', ADatabase);
end;
end;
end;
Walk-through:
In the main code block, loop through each database belonging to the current instance.
for f := 0 to Instance.DatabaseCount - 1 do
...
end;
Get a reference to each database.
// get a reference to each database in the loop
ADatabase := Instance.Database(f);
Check if the databases’ transaction log size is larger than 1 gigabyte.
if ADatabase.LogSize > (1 * GB) then
begin
...
end;
If it is, raise an alert, an also show the transaction log size and the database size.
RaiseAlert('Transaction log size is > 1 GB. Current size is ' +
FormatBytes(ADatabase.LogSize) + '. Database size is ' + FormatBytes(ADatabase.Size) +
'.', ADatabase);
•
analyse database growth easily using charts and graphs
•
raise alerts when database growth exceed expectations
•
identify the largest and fastest growing data files quickly
•
have growth reports sent to you daily via email
•
supports SQL Server 2005 and newer versions
Analyse SQL Server database
and table growth using
SQL Size