Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Check db status

$
0
0

I have a SSIS package that routinely fails because one of the source DBs is being restored at the time my package runs. I want to put in a check to see if the db is online - that's easy enough by running this query in an Exec SQL step and passing the results to a Var.

SELECT

DBStatus = CASE WHEN state_desc ='Online' THEN 1 ELSE 0 END

FROM sys.databases

WHERE name ='MyDB'

I will then evaluate the Var that is populated from the above query. The easy part is that if the conditional expression evaluates to True, I will continue. The hard part is what if it’s false?  I wanted to put in another SQL Task with this: ”WAITFOR DELAY '00:01:00'”, and then go back to the top to check the status again. I’m able to drag the arrow from the Wait task back to the Check Status task, but I can’t drag the arrow from the Check Status to the Wait. I already have a conditional precedence expression from the Check Status to my Step1 task, but when I try to drag an arrow from Check Status to Wait I get the error: “Cannot create connector. A task would indirectly depend upon itself…”  So how can I accomplish what I want to do? This is what I want to do:

Check the status of a Database.

If the status is online, proceed to Step 1

If the status is not online, wait for 1 minute then check the status again.

Thanks in advance.

André


André


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>