我需要从我自己的过程中执行rds_restore_database存储过程,所以我需要在执行之后得到rds_task_status,因为等待恢复是成功的。
在还原之后,我不知道如何在变量中获得task_id:
exec msdb.dbo.rds_restore_database 'whatever', 'S3_bucket_bak'我不知道如何让其他变量中的生命周期列检查还原状态:
exec [msdb].[dbo].[rds_task_status] @task_id=@mytaskid我尝试的唯一方法是将结果插入到临时表中:
INSERT INTO #MyTempTable exec @task_id = msdb.dbo.rds_restore_database 'whatever', 'S3_bucket_bak'但是,无论何时我想检查恢复状态如何,我都必须删除并再次插入。
还有别的解决办法吗?
发布于 2022-07-24 11:25:58
我能找到的最好的解决办法是:
declare @my_task_id int
select top 1 @my_task_id = task_id from msdb.dbo.rds_fn_task_status(NULL,0) order by task_id desc
select @my_task_id task_id或者,如果您想要做的和我一样,在完成所有任务之前停止代码执行,那么下面的操作应该有效:
declare @sec int = 0;
WHILE ((SELECT top 1 lifecycle FROM msdb.dbo.rds_fn_task_status(NULL,0) order by task_id desc) <> 'SUCCESS')
BEGIN
WAITFOR DELAY '00:00:10';
set @sec = @sec + 10
if @sec >= 1800 RAISERROR ('Timout. Copying from S3 to RDS server took more than 30 minutes.',16,1)
END如果rds团队创建的存储过程只返回task_id就好多了。但他们不知道所以..。
https://stackoverflow.com/questions/72606692
复制相似问题