Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I would like to add a condition to a sequence in my SQL Server 2008 Maintenance Plan. This condition is based on the variable set by a T-SQL Statement Task:

declare @primary bit = 0
select @primary=1
from sys.database_mirroring
where mirroring_role = 1

How can I perform this task through the precedence constraint editor?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I agree with SQLChicken. You won't be able to check the variables via a simple maintenance plan you create in SQL Management Studio. You will need to either script it out and put it in a SQL job or create a full-on SSIS package. SSIS will provide you with all of the maintenance plan tasks that are available via SSMS as well as all of the other benefits of SSIS including package variables that you can use in your precedence constraints.

share|improve this answer
Thanks, indeed, I had to go through SSIS to add variables. I did manage to edit the maintenance plan on SSIS and upload it back to SQL Server, but there is no real added value to use maintenance plans now... –  Idriss Aug 13 '09 at 10:10

Honestly if you're going to get into advanced tweaking like that you're better off scripting a solution and then scheduling it via Agent. Maint Plans, while nice for really simple tasks, really has its limitations.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.