您的位置:首页 > 数据库

The SQL Server Service Broker for the current database is not enabled

2016-10-24 22:17 876 查看
把一个数据恢复至另一个服务器上,出现了一个异常:

The SQL Server Service Broker for the current database is not enabled, and as a result query notifications are not supported. Please enable the Service Broker for this database if you wish to use notifications.

截图如下:

DECLARE @DBName SYSNAME

SET @DBName = 'Tutorial'  --'Your DB Name'

DECLARE @spid INT
SELECT @spid = MIN(spid) FROM [MASTER].[dbo].[sysprocesses] WHERE dbid = DB_ID(@DBName)
WHILE @spid IS NOT NULL
BEGIN
EXECUTE ('KILL ' + @spid)
SELECT @spid = MIN(spid)  FROM [MASTER].[dbo].[sysprocesses] WHERE dbid = DB_ID(@DBName) AND spid > @spid
END

EXECUTE('ALTER DATABASE '+ @DBName +' SET ENABLE_BROKER')   --DISABLE_BROKER


Source Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐