I was ‘trying’ to delete an obselete SQL Server Agent job until this nice error popped up:
The DELETE statement conflicted with the REFERENCE constraint "FK_subplan_job_id". The conflict occurred in database "msdb", table "dbo.sysmaintplan_subplans", column ‘job_id’.
The statement has been terminated. (Microsoft SQL Server, Error: 547)
Drop failed for Job ‘MYMAINTENANCEPLAN.Subplan_1′. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Actions Required to Resolve this Error:
Type this command in your SQL server query box.
use msdb go select * from sysmaintplan_subplans delete from sysmaintplan_subplans
It should work for you, as this solution has solved many user’s problem related to Maintenance Plan.
You can check out my Previous post