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;

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...