Sqlmaint.exe is a command line program that can be used to run database maintenance commands from a command prompt.
It can do the following
- Run DBCC checks
- Back up a database
- Back up a transaction log
- Update statistics
- Rebuild indexes
- Send reports to a text file, HTML file, or email account
Here is what the syntax of sqlmaint.exe looks like:
If you want to use integrated security when you are using sqlmaint, you do not specify anything for the username and password.
If you are not using integrated security, you may need to include the username and password in double quotes.
After running sqlmaint, you should check the output to validate that it worked correctly and that any dbccs performed did not generate an error.
If it runs correctly, you will only see the output generated by the dbccs that shows what tasks were performed.
When running sqlmaint, Microsoft recommends that you DO NOT use the dbcc newalloc command or the dbcc textalloc command. This is because they are planning on getting rid of the command.
Here are some examples of how you might use sqlmaint.exe to accomplish various maintenance tasks based on specific conditions.
This example of sqlmaint.exe will run dbcc checkdb on the Customer database using standard security.
Before you continue, click the Exercise link below to check your understanding of the sqlmaint.exe syntax.
Using SQLmaint.exe - Exercise
The next lesson will show you how to use the database maintenance plan Wizard.