I was just adding a small Ad-Hoc maintenance plan on our shiny new SQL Server 2012 test boxes, when I received the following error message:
Adding tasks to the maintenance plan failed: Object reference not set to an instance of an object.
This is a short post that goes through some reasons as to why this error message might appear.
The SQL Server Maintenance Plan is a very nice and “wizard-y” way of creating and automating database maintenance activities, such as Index Rebuilding, Database Backups, Database Restores, Statistics Update, and so on. It is extremely simple to setup, and can be extended in a fairly straight forward manner.
The Maintenance Plan is actually built on-top of a few services Microsoft releases with SQL Server, including SSIS and SQL Server Job Agent, hence your server needs to have SSIS in order to build the maintenance plan, and Job Agent in order to schedule the maintenance plan to run at regular periods.
The error message: Adding tasks to the maintenance plan failed: Object reference not set to an instance of an object is an indication that one of the required component for my plan was not available on the server, in my case, I didn’t have SQL Server Integration Services installed on that machine.
SQL Server Job Agent is not required to generate a maintenance plan, but it is only required to schedule the plan, and so you should still be able to create a maintenance plan without Job Agent.
Hope this helps.