File Group Alert in Microsoft SQL Server

Vijay
Vijay used Ask the Experts™
on
Hi,

We ahave created multiple file groups in SQL Server 2008 R2 with initial size 10 GB.
Now i want to create an alert on file groups like, if available space less than 20% it should trigger an alert (some sql job kind of alert)
so that immidiately i will allocate more free space to that file group.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Database Expert
Awarded 2016
Top Expert 2016
Commented:
>>We ahave created multiple file groups in SQL Server 2008 R2 with initial size 10 GB.
Not sure about file groups but for files we can set an alert.

Please read this from Microsoft. Please let us know if you need any modifications.
IF EXISTS
(
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 [LOG File(s) Size (KB)] >1000
)
BEGIN 

EXEC msdb.dbo.sp_send_dbmail 
     @profile_name = 'Administrator', 
     @recipients = 'mmmm@mail.com',
     @subject = @Subject,
     @body=@body

END

Open in new window


From - https://social.msdn.microsoft.com/Forums/sqlserver/en-US/706359ab-d7e7-4ad0-a125-2691472986e4/how-to-create-an-alert-which-notifies-me-if-my-logspace-reaches-a-threshold-percentage?forum=sqlsetupandupgrade

Author

Commented:
Good information.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial