Skip to content

Sahista-Patel/SQL-LogFileSizeShrink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SQL-LogFileSizeShrink

This script will check the Log file size. If free file space is less than 20% that mean byond threshold and qualifies for the alert. It sends E-mail by combining all these alerts (example mentioned in o/p) then it will wait For 10 Minutes. After 10 minutes it will take backup first the shrink the log file without manual intervention.

Alert serial number, Server Name, Database Name, %Free File Space - Free log file space. It will send an email, if scheduled then it is monitoring as well as log file size auto handling technique.

Prerequisites

SQL Server SSMS - SQL Server Management Studio

Note

Set SSMS E-Mail Profile
Alert - Serial number
Server Name - Machine Name
Database Name - Database Name of which log file belong
Free Space (%) - Free Space of the log file in Ratio (%)

Use

Create profile and script in SSMS then schedule it as per requirement.

Input

@profile_name = 'LogFileSizeAlert', -- Replace with your SQL Database Mail Profile
@body = @body,
@body_format ='HTML',
@recipients = '[email protected]', -- Replace with your email address
@subject = 'Log File Beyond Threshold' ;

Example O/P

alt text

License

Copyright 2020 Harsh & Sahista

Contribution

[Harsh Parecha] (https://github.com/TheLastJediCoder)
[Sahista Patel] (https://github.com/Sahista-Patel)
We love contributions, please comment to contribute!

Code of Conduct

Contributors have adopted the Covenant as its Code of Conduct.. Please understand copyright and what actions will not be abided.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages