sql-server – 如何以编程方式启用SQL Server中的READ COMMITTED SNAPSHOT?

前端之家收集整理的这篇文章主要介绍了sql-server – 如何以编程方式启用SQL Server中的READ COMMITTED SNAPSHOT?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要以编程方式启用sql Server中的READ COMMITTED SNAPSHOT.我怎样才能做到这一点?

解决方法

我建议先切换到单用户模式.这确保你是唯一的连接.否则,查询可能会被暂停.

来自:http://msdn.microsoft.com/en-us/library/ms175095.aspx

When setting the
READ_COMMITTED_SNAPSHOT option,only
the connection executing the ALTER
DATABASE command is allowed in the
database. There must be no other open
connection in the database until ALTER
DATABASE is complete.

所以,使用这个sql

ALTER DATABASE <dbname> SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE <dbname> SET READ_COMMITTED_SNAPSHOT ON;
ALTER DATABASE <dbname> SET MULTI_USER;
原文链接:https://www.f2er.com/mssql/82168.html

猜你在找的MsSQL相关文章