Overview
It is recommended to check the SQL database regularly e.g. once a week by running the dbcc checkdb -command.
Running this command periodically helps to detect possible underlying corruption more quickly in the database files as this may remain undetected for long periods and thus affecting also backups.
Solution
You can configure the database maintenance plan in SQL Management Studio to automate the SQL Server DBCC CheckDB process.
- To create a maintenance plan, Launch SQL Server Management studio -> Right-click on Management -> 'Select New Maintenance Plan…'
- Specify the appropriate name of the maintenance plan
- Drag the 'Check Database Integrity Task' from the maintenance plan toolbox and drop it on the Maintenance plan designer window
- To configure the SQL Server DBCC CheckDB, double click on 'Check Database Integrity Task'. A dialog box opens
- Configure the connection, click on 'New..'. Specify the Connection Name in the 'Connection name' textbox and specify the hostname in 'Specify the following to connect to SQL Server data' text box.
- Click OK to create the connection and close the dialog box
- In Databases: choose 'All User Databases' and exclude the databases that are not ONLINE, check the option 'Ignore databases where the state is not an online' and click OK
- Select options 'Include indexes' and 'Physical Only'
- Click OK to save the configuration of the 'Check database integrity task' and close the dialog box
- Configure the job schedule, click on the calendar icon in maintenance plan designer
- In the New Job Schedule dialog box, set the values of parameters e.g. shown below:
Schedule Type: Recurring
Occurs: Weekly
Recurs every: 1 week on Saturday
Occurs once at 0:00:00
If you click 'Reporting and Logging' icon in the Maintenance plan designer, you can define where the reports and logs are stored.
For the more detailed steps and pictures, please check this web page:
https://www.sqlshack.com/automate-the-sql-server-dbcc-checkdb-command-using-maintenance-plans/
Please note that M-Files is not responsible of content of 3rd party web pages.
Please see also the following article:
