1. 程式人生 > >SQL Server刪除distribution資料庫及相關問題解決方案

SQL Server刪除distribution資料庫及相關問題解決方案

         在資料庫伺服器刪除複製(釋出訂閱)後,如何刪除掉資料庫distribution呢?如果你通過SSMS工具去刪除資料庫distribution,你會發現沒有刪除選項。那麼怎麼刪除呢?

  刪除distribution步驟


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

                exec sp_helpsubscriberinfo ;
               go
 
              exec sp_dropsubscriber 'SubscriberName';
              go


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


exec sp_helpdistpublisher;

go


exec sp_dropdistpublisher  @publisher = 'PublisherName';

go

步驟3: 使用sp_dropdistributiondb刪除資料庫distribution


use master;
go
 
exec sp_dropdistributiondb @database = N'distribution'
go
 
use master; 
go 
 
exec sp_dropdistributor @no_checks = 1, @ignore_distributor = 1 
go

 

在刪除過程中,我遇到一些問題,下面是問題描述及解決方案

1、執行

exec sp_dropdistributiondb @database = N'distribution'

GO

出現錯誤資訊“Could not drop the distribution database 'distribution'. This distributor database is associated with a Publisher.”

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

2、執行

exec sp_dropdistributiondb @database = N'distribution'

go

出現錯誤資訊“Cannot drop the distribution database 'distribution' because it is currently in use”

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

 use master 
go 
 
alter database distribution set offline; 
go
 
drop database distribution;

3、錯誤資訊:由於伺服器 '%s' 上存在已設定為允許複製的資料庫,因此無法將該伺服器作為分發釋出伺服器進行刪除

描述:該儲存過程在釋出伺服器的釋出資料庫中或在訂閱伺服器的訂閱資料庫中執行。 該過程將從執行它的資料庫中刪除所有複製物件,但它不會從其他資料庫(例如,分發資料庫)中刪除物件。


解決方案:sp_removedbreplication 'XXX'    XXX---移除允許複製的資料庫。

 

4、無法獲取有關Windows NT 組\使用者‘組\使用者’的資訊,錯誤程式碼0x5(Microsoft SQL Server,錯誤:15404)


       ALTER AUTHORIZATION ON DATABASE:: [資料庫名] TO [sa]