Export (0) Print
Expand All
Expand Minimize


SQL Server 2000

  New Information - SQL Server 2000 SP3.

Calls the sqlmaint utility with a string containing sqlmaint switches. The sqlmaint utility performs a set of maintenance operations on one or more databases.


xp_sqlmaint 'switch_string'



Is a string containing the sqlmaint utility switches. The switches and their values must be separated by a space.

The -? switch is not valid for xp_sqlmaint.

Return Code Values

None. Returns an error if the sqlmaint utility fails.


If this procedure is called by a user logged on with SQL Server Authentication, the -U "login_id" and -P "password" switches are prepended to switch_string before execution. If the user is logged on with Windows Authentication, switch_string is passed without change to sqlmaint.


Execute permissions for xp_sqlmaint default to members of the db_owner fixed database role in the master database and members of the sysadmin fixed server role, but can be granted to other users.


In this example, xp_sqlmaint calls sqlmaint to perform integrity checks, create a report file, and update msdb.dbo.sysdbmaintplan_history.

EXEC xp_sqlmaint '-D pubs -PlanID 02A52657-D546-11D1-9D8A-00A0C9054212 
   -Rpt "C:\Program Files\Microsoft SQL Server\MSSQL\LOG\DBMaintPlan2.txt" -WriteHistory  -CkDB -CkAl' 

Here is the result:

The command(s) executed successfully.

See Also

sqlmaint Utility

System Stored Procedures

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft