I have a procedure that should be run just after databases are restored. For that, I want to make a job with 2 steps:
- Checking the databases’ status at time intervals
- Procedure, triggering after Step 1 on success
For Step 1, I want to use this query to retrieve status:
SELECT msd.state_desc
FROM [master].[sys].[databases] msd
Checking for certain databases that are not in state state_desc RESTORING
. If this condition is met, the second step should trigger.
I was thinking about doing this in SSIS
. Which blocks should I use for this check? Or is it better to use just T-SQL
?
Searched the web for solutions, but without success.