Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using SQL Server 2008 and have a Maintenance Plan setup that does a DBCHECK before the nightly backup.

This has been working fine for months. It has started failing. If I run a DBCHECK on the Databases, they are pass fine. I even went into the maintenance plan and clicked 'View SQL' to get the TSQL that is run during the Plan and it again all passed:

USE [ClientPortal]
USE [PHJ_Common_Objects]
USE [PilotWebApp]
DBCC CHECKDB(N'PilotWebApp')  WITH NO_INFOMSGSenter code here

Why would this fail during the plan but work fine when run manually?

share|improve this question

migrated from Jan 22 '12 at 6:55

This question came from our site for professional and enthusiast programmers.

The maintenance plan is usually executed with another user account. Check the properties of SQL Agent. If the Connection tab specifies Use Windows Authentication, it runs under the same user as the SQL Server Agent service. You can see that in the Local Services control panel, under the Log On tab.

Once you figure out the user account, try to run the script as that user.

share|improve this answer

Going forward, if you have the time, I'd suggest implementing a stored procedure/job approach to maintenance such as CheckDB. They are much more robust and scalable than maintenance plans, in my opinion.

Ola Hallengren offers excellent maintenance scripts, which are easy to deploy:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.