我有啓用Service Broker的DataBase。然後,我想從其他數據庫的備份恢復我的數據庫中的程序,但恢復(我恢復現有的數據庫名)之後,我的方法,whitch使服務代理,把這個錯誤:恢復Sql Server數據庫後啓用代理
Msg 9772, Level 16, State 1, Line 1
The Service Broker in database "ServeDB2" cannot be enabled because there is already an enabled Service Broker with the same ID.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed.
這是我的方法:
public void TurnOnBroker()
{
if (!this.database.BrokerEnabled)
{
this.server.KillAllProcesses(this.database.Name);
this.database.BrokerEnabled = true;
this.database.Alter();
RefreshConnection();
}
}
我應該怎麼解決?有什麼建議嗎?
終止進程是活潑和殺戮不一定立竿見影。更好地使用'WITH ROLLBACK IMMEDIATE'。 – usr 2017-08-16 13:13:16