我需要以编程方式启用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;