我的数据库启用了Service Broker。然后我想从另一个数据库的备份中在程序中恢复我的数据库,但是在恢复后(我在现有的数据库名称上进行恢复),我的方法会出现以下错误:
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