';立即回滚';SQL Server 2012不工作

';立即回滚';SQL Server 2012不工作,sql,sql-server,sql-server-2012,Sql,Sql Server,Sql Server 2012,我正在尝试启用service broker并立即回滚,请参阅本文: 问题是: alter database fooDB set enable_broker with rollback immediate; 但是,它在SQL Server 2012中给了我以下语法错误: Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'with'. Msg 319, Level 15, State 1, Line 2 In

我正在尝试启用service broker并立即回滚,请参阅本文:

问题是:

alter database fooDB set enable_broker with rollback immediate;
但是,它在SQL Server 2012中给了我以下语法错误:

Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'with'.
Msg 319, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near 'immediate'.

在SQL Sever 2012中如何实现这一点?

也许在自己的批处理中使用前置和终止“GO”将有所帮助

GO
alter database fooDB set enable_broker with rollback immediate;
GO

我刚刚看了另一篇文章,你是想在特定的表上执行此操作,还是脚本要动态运行?

启用代理选项需要独占的数据库锁。更改后的数据库上不应有任何具有锁的会话,它还包括运行它的会话:

use master;

alter database fooDB set enable_broker with rollback immediate;

发布给您问题的查询plz…您的查询出现以下问题:“如果此语句是公共表表达式、xmlnamespaces子句或更改跟踪上下文子句,则前一个语句必须以分号结尾”,因此我们需要您的查询来帮助您。我已添加了此查询,它是从另一个数据库复制的。你的真实数据库名称中有空格吗?真实数据库名称中没有空格…该语句在语法上没有错误。您的查询窗口中一定还有其他内容。