Email the results of DBCC CHECKDB

Situation:

We had a very busy SQL Server, that could not have “DBCC CHECKDB” run during business hours with out impacting others.  I was being asking for the output from the “DBCC CHECKDB” job.  What I wanted was a nice script that would run in the middle of the night, and e-mail the output from the “DBCC CHECKDB”, so that I could forward the output file as an email attachment.

Resolution:

I inserted the following sql script in a SQL Agent job & scheduled the job to run in the middle of the night:

EXECUTE msdb.dbo.sp_send_dbmail
@profile_name = 'DBA',
@recipients = 'myemail@mycompany.com;',
@Subject = 'My SQL Server DBCC CHECKDB Results',
@query = N'USE MyBusyDB; DBCC CHECKDB;',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'CheckDBOutput.txt'
GO
Emailed DBCC CHECKDB Output

Emailed DBCC CHECKDB Output

Comments are closed.