0

有没有办法为某些 sql 查询使用ReadCommited事务隔离级别,同时为其他查询使用ReadCommitedSnapshot

据我所知,我以前在ReadCommited IL下运行的所有事务一旦我的数据库 将切换到RCS 。SET READ_COMMITTED_SNAPSHOT ON

.NET我只有IsolationLevel.ReadCommited.

当然,我不能只SET READ_COMMITTED_SNAPSHOT在每次查询之前打开/关闭,因为它需要非常单一的 sql 连接(实际上需要一些时间)。

有什么选择吗?

编辑:上!!!!

4

2 回答 2

1

At the SQL Server level, provided that ALLOW_SNAPSHOT_ISOLATION is ON, you can control it by using SET ISOLATION LEVEL statements. Don't turn on READ_COMMITTED_SNAPSHOT.

In that way, those connections that should have normal RC just run:

SET TRANSACTION ISOLATION LEVEL READ_COMMITTED

(Or do nothing)

And for the connections where you want "RCS", run:

SET TRANSACTION ISOLATION LEVEL SNAPSHOT
于 2013-07-12T08:27:32.337 回答
0

使用快照隔离级别,它实际上映射到 READ_COMMITTED_SNAPSHOT 这里是 msdn 链接 http://msdn.microsoft.com/en-us/library/system.transactions.isolationlevel.aspx

于 2013-06-21T12:51:26.613 回答