久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

等待快照代理狀態完成的 T-SQL 腳本

T-SQL script to wait till status of snap agent is completed(等待快照代理狀態完成的 T-SQL 腳本)
本文介紹了等待快照代理狀態完成的 T-SQL 腳本的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在嘗試構建一個 SQL 腳本,以便在刪除復制之前等待快照代理完成創建快照(如果正在進行)

I'm trying to build a SQL script to wait till snapshot agent finish create snapshot (if it is in progress) before dropping the replication

當前狀態:我們有一些 SQL 腳本來禁用復制(它們作為 VSTS 發布管道的一部分運行).有時,可能會生成快照.如果在執行快照時禁用復制,腳本將失敗.

Current status: We have some SQL scripts to disable replication (they are run as part of VSTS release pipelines). Sometimes, there might be a snapshot being generated. If replication is being disabled while a snapshot is in progress, script fails.

我正在使用下面的腳本來檢查快照代理的狀態

I'm using below script to check the status of snapshot agent

選擇狀態從 dbo.MSReplication_monitordataWHERE 發布 = 'PublicationName' 和 agent_type = 1) = 3

SELECT status FROM dbo.MSReplication_monitordata WHERE publication = 'PublicationName' and agent_type = 1) = 3

最終目標:

我需要幫助以實現以下目標:

I want help to achieve the following:

腳本檢查快照代理是否正在運行.如果它正在運行,它將等待它完成(生成快照),然后執行操作(刪除復制).

script check if snapshot agent if running or not. If it is running, it will wait till it is completed (snapshot generated), then do the action (drop replication).

我已經有了刪除復制的腳本,我需要幫助的是處理這種情況的邏輯.

I already have the scripts for dropping replication, what I need help about is the logic to handle this scenario.

我的問題不是來自 如何檢查復制快照代理狀態?

我需要有關邏輯的幫助以創建腳本以等待快照代理空閑(如果它正在運行).我不知道如何在 t-sql 中做到這一點.

i need help with the logic to create a script to wait till snapshot agent is idle (if it is running). I don't know how to do it in t-sql.

我相信 (waitfor) 或 (while) 會有所幫助,但我不知道如何使用它們.

I believe (waitfor) or (while) will help, but I don't know how to use them.

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/waitfor-transact-sql?view=sql-server-2017https://docs.microsoft.com/en-us/sql/t-sql/language-elements/while-transact-sql?view=sql-server-2017

推薦答案

我能夠使用 while 循環使用以下內容:

I was able to use while loop using below:

    use [distribution];
    declare @status int = 2

     select @status = status
     FROM dbo.MSReplication_monitordata
     WHERE publication = 'PublicationName' and agent_type = 1

     while @status = 3
     begin
     WAITFOR DELAY '00:00:03'
     select @status = status
     FROM dbo.MSReplication_monitordata
     WHERE publication = 'Publication.Name' and agent_type = 1
     end

這篇關于等待快照代理狀態完成的 T-SQL 腳本的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Modify Existing decimal places info(修改現有小數位信息)
The correlation name #39;CONVERT#39; is specified multiple times(多次指定相關名稱“CONVERT)
T-SQL left join not returning null columns(T-SQL 左連接不返回空列)
remove duplicates from comma or pipeline operator string(從逗號或管道運算符字符串中刪除重復項)
Change an iterative query to a relational set-based query(將迭代查詢更改為基于關系集的查詢)
concatenate a zero onto sql server select value shows 4 digits still and not 5(將零連接到 sql server 選擇值仍然顯示 4 位而不是 5)
主站蜘蛛池模板: 成人免费激情视频 | 岛国在线免费观看 | 国产成人jvid在线播放 | 狠狠视频 | 欧美另类视频在线 | hdfreexxxx中国妞| 成人免费网站www网站高清 | 国产成人免费视频网站高清观看视频 | 毛片免费看 | 亚洲一区国产精品 | 一区二区三区视频在线观看 | 婷婷精品| 久久精品国产久精国产 | 免费观看日韩精品 | 欧美日韩久| 91精品中文字幕一区二区三区 | 欧美精品在线一区二区三区 | 丝袜美腿一区二区三区动态图 | 国内久久 | 日韩精品av| 免费黄色在线观看 | 成人久久一区 | 国产精品中文字幕一区二区三区 | 国产精品 欧美精品 | 久久久精 | 精品一区二区三区视频在线观看 | 精品免费视频 | 国产精品一区二区视频 | 久久狼人天堂 | 欧美一级片在线看 | 超碰美女在线 | cao在线 | 99reav| 久久久久久看片 | 国产a区 | 91精品国产91久久久久久丝袜 | 中文字幕一区二区三区在线观看 | 在线观看国产www | 成人国产精品一级毛片视频毛片 | 午夜激情视频 | 91在线视频 |