当我尝试在事务内运行RECONFIGURE语句时,会出现以下错误:
无法在用户事务内使用CONFIG语句。
有没有任何异步运行此命令或其他方法可以修复错误的方式?
这是一个简化版本的重现错误的操作:
BEGIN Transaction
EXEC sp_configure 'clr enabled', 1
RECONFIGURE
Commit Transaction
当我尝试在事务内运行RECONFIGURE语句时,会出现以下错误:
无法在用户事务内使用CONFIG语句。
有没有任何异步运行此命令或其他方法可以修复错误的方式?
这是一个简化版本的重现错误的操作:
BEGIN Transaction
EXEC sp_configure 'clr enabled', 1
RECONFIGURE
Commit Transaction
事务是一种构造,可以回滚(撤消)您所做的操作,例如插入、更新等。重新配置服务器不是事务可以回滚的内容。这就是为什么在事务中不允许这样做的原因。由于此处事务无法带来任何好处,因此请从脚本中删除它。
来自Technet:
您可以在显式事务中使用所有的Transact-SQL语句,但以下语句除外:
您也不能使用以下内容:
Full-text system stored procedures in an explicit transaction.
sp_dboption to set database options or use any system procedures that modify the master database inside explicit or implicit transactions.
UPDATE STATISTICS can be used inside an explicit transaction. However, UPDATE STATISTICS commits independently of the enclosing transaction and cannot be rolled back.