How to automate DBCC CHECKDB in MS SQL 2016?
In this post I would like to show you how I solved the automation of DBCC CHECKDB. I had a meeting with a Microsoft engineer about MS SQL and he told me it is recommended to run this command runs regularly. At least once a week during the night hours because DBCC CHECKDB generates a lot of IO operations.
Here is my solution:
1) Create table CheckDB:
- This Proc save the result of DBCC CHECKDB(0) WITH TABLERESULTS to the table CheckDB in the first step.
I have created new job that consisted of 3 steps.
1 Step - Exec procedure DBCC_CHECKDB
2 Step - Delete rows when CreateDate is older than 2 months
3 Step - Send information mail with results
I hope you will find it as helpful as I do!