我正在尝试按照以下帖子启用服务代理并立即回滚:Enable SQL Server Broker taking too long time
这里是查询:
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中执行此操作?
答案 0 :(得分:0)
也许将它包装在它自己的批次中,然后终止" GO"会有帮助吗?
GO
alter database fooDB set enable_broker with rollback immediate;
GO
我只看了另一篇文章,您是否尝试在特定的表上执行此操作,或者脚本是否可以动态运行?
答案 1 :(得分:0)
enable_broker
选项需要独占数据库锁。应该没有任何会话在更改的数据库上有任何锁定,它还包括您运行它的会话:
use master;
alter database fooDB set enable_broker with rollback immediate;