Error al querer eliminar un job de SQL Server 2005

by 9. julio 2009 17:34

Al intentar eliminar un Job del SQL Server 2005 puede aparecer el siguiente mensaje de error

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)

nos indica que no se puede eliminar un job por problemas con los planes de mantenimiento.

Para poder resolver este problema y poder eliminar el Job les dejo el siguiente Script

declare @job_name varchar(500)

set @job_name = N'tujob' ;

 

USE [msdb]

delete sysmaintplan_log

FROM sysmaintplan_subplans AS subplan

INNER JOIN

sysjobs_view AS jobs ON subplan.job_id = jobs.job_id INNER JOIN

sysmaintplan_log ON subplan.subplan_id = sysmaintplan_log.subplan_id

WHERE (jobs.name = @job_name)

 

delete sysmaintplan_subplans

FROM sysmaintplan_subplans AS subplan INNER JOIN

sysjobs_view AS jobs ON subplan.job_id = jobs.job_id

WHERE (jobs.name = @job_name)

 

delete

from msdb.dbo.sysjobs_view where name = @job_name

Tags:

How To

Comentarios

13/08/2009 23:47:36 #

I would like to add your blog to my blogroll please tell me what anchor should I use?

Eos Womens Safire Swaroski United States

14/08/2009 22:17:12 #

Would you like to post a guest post on my blog?

Bulova Mens Watch 96d10 United States

15/08/2009 21:28:23 #

I am quite interesting in this topic hope you will elaborate more on it in future posts.

Calvin Klein Chronograph Silver United States

16/08/2009 20:22:01 #

I think you have to improve a bit the design and usability of your blog.

Longines L5 158 0 71 6 Watch United States

17/08/2009 19:48:44 #

I like your blog curently we are looking for a part time article writer would you be interested?

Guess Collection G34500g4 Mens United States

18/08/2009 17:41:56 #

Hey I love your style I will subscribe for your feed please keep posting!

Charriol Columbus Diamond Ladies United States

26/08/2009 9:24:56 #

Tried to autotranslate you site not understand the writing any hope deutsch version?

Baume Mercier Classima United States

27/08/2009 7:18:29 #

Do you earn decent money from this blog or are you doing it just for fun?

Baume Mercier Classima United States

27/08/2009 19:25:42 #

Thank you for your help!

bad credit loans United States

Maximiliano Damian Accotto