title: How do SQL Server isolation levels work with views?
body: <p>I have a SQL Server 2012 database with <code>Set Allow Snapshot Isolation = TRUE</code>.  Let's call it <code>DBSnap</code>.</p>
  
  <p>I have another database with <code>Set Allow Snapshot Isolation = FALSE</code>. Let's call it <code>DBRead</code>.</p>
  
  <p>In <code>DBSnap</code>, I have a created a view to a table in <code>DBREAD</code> (called the same name for ease of reference):  </p>
  
  <pre><code>Create View DBReadTable 
  as 
      Select * 
      from DBRead.dbo.DBReadTable.
  </code></pre>
  
  <p>If I execute the following commands, they fail:</p>
  
  <pre><code>set transaction isolation level snapshot
  
  Select * 
  from DBRead.dbo.DBReadTable
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>Msg 3952, Level 16, State 1, Line 2<br>
    Snapshot isolation transaction failed accessing database 'DBRead' because snapshot isolation is not allowed in this database. Use ALTER DATABASE to allow snapshot isolation.</p>
  </blockquote>
  
  <p>However if I execute these commands, basically access a table in the DBRead database form a view in DDSnap:</p>
  
  <pre><code>set transaction isolation level snapshot
  
  Select * 
  from DBSnap.dbo.DBReadTable
  </code></pre>
  
  <p>It works.</p>
  
  <p>What is actually happening in the second instance?  </p>
  
  <p>Is row versioning being done by <code>DBSnap</code> for the table in <code>DBRead</code> (i.e. does the <code>DNSnap</code> view have row version information)? </p>
  
  <p>Or is a lock being placed on table <code>DBRead</code>?</p>
  
  <p>Thank you,</p>
  
  <p>Graeme Black</p>