天天看點

SQL Server删除distribution資料庫

  在資料庫伺服器删除複制(釋出訂閱)後,如何删除掉資料庫distribution呢?如果你通過ssms工具去删除資料庫distribution,你會發現根本沒有删除選項。 下面介紹一下删除distribution的步驟

步驟1: 檢視相關訂閱伺服器的資訊,如果還存在對應的訂閱伺服器,從注冊的伺服器中删除訂閱伺服器名稱

步驟2: 檢視分發伺服器的釋出伺服器的屬性

步驟3: 删除分發釋出伺服器

步驟4: 使用sp_dropdistributiondb删除資料庫distribution

注意事項:

1:錯誤資訊“could not drop the distribution database 'distribution'. this distributor database is associated with a publisher.”

exec sp_dropdistributiondb @database = n'distribution'

go

消息 14120,級别 16,狀态 1,過程 sp_dropdistributiondb,第 85 行

could not drop the distribution database 'distribution'. this distributor database is associated with a publisher.

SQL Server删除distribution資料庫

出現這個錯誤,是因為必須先删除對應的分發釋出伺服器,否則就會出現下面錯誤。

2:錯誤資訊“cannot drop the distribution database 'distribution' because it is currently in use”

消息 21122,級别 16,狀态 1,過程 sp_dropdistributiondb,第 124 行

cannot drop the distribution database 'distribution' because it is currently in use.

出現上面情況,是因為會話視窗使用的資料庫是distribution,你可以指定會話視窗的資料庫為master或使用下面語句即可解決問題。

另外由于某些原因,導緻無法使用sp_dropdistributiondb删除distribution資料庫。此時可以使用下面方式強制删除資料庫distribution。

SQL Server删除distribution資料庫