The following SlideShow explains the syntax of sqlmaint.exe. in line-by-line detail.
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.
sqlmaint -S MyServer -U "sa" -P "SaPwd" -D Customer -CkDB
This example performs an update statistics on all tables in the Sales databases using integrated security.
sqlmaint -S MyServer -U "" -P "" -D Sales -UpdSts
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.