title: Database VIEW does not reflect the data in the underying TABLE
body: <h2>Input:</h2>
  
  <p>The customer claims that the application (.NET) when querying for some data returns data different from when the customer looks into the data table directly.</p>
  
  <p>I understand there could be various reasons and in completely different places. My purpose is not to solve it here, but rather to ask experienced DBAs and DB developers if:</p>
  
  <h2>Is it possible for a VIEW to show data that does not match the underlying TABLE(s)?</h2>
  
  <ul>
  <li><strong>What are possible causes/reasons for this?</strong></li>
  <li>Can an UPDATE statement on a view cause future SELECTs to return 'updated' data, when the table really does not?</li>
  </ul>
  
  <h2>Possible causes (please comment on those with question-marks):</h2>
  
  <ol>
  <li>the reason is that there are two separate transactions, which would explain the customers' confusion.</li>
  <li>the underlying table was altered, but the view was not refreshed (using sp_refreshview)</li>
  <li>a different user is connecting and can see different data due to permissions ?</li>
  <li>programmer error: wrong tables/columns, wrong filters (all-in-one here)</li>
  <li>corruption occurs: DBCC CHECKDB should help</li>
  <li>can <code>SELECT ... FOR UPDATE</code> cause this <strong>???</strong></li>
  <li>? __</li>
  </ol>
  
  <h2>What really happened (THE ANSWER):</h2>
  
  <p>Column positions were altered in some tables: Apparently the customer gave full database access to a consultant for database usage analysis. That great guy changed the order of the columns to see the few <em>audit</em> fields at the beginning of the table when using <code>SELECT * ...</code> clauses.</p>
  
  <p>Using <a href="http://www.innovartis.co.uk/products/products.aspx" rel="noreferrer">dbGhost</a> the database schema was compared to the schema of the backup taken few days before the problem appeared, and the column position differences were discovered.</p>
  
  <p>What came next was nothing related to programming, but more an issue of politics.</p>
  
  <p>Therefore the <code>sp_refreshview</code> was the solution. I just took one step more to find who caused the problem. Thank you all.</p>