title: sql server 2008 case statement in where clause not working
body: <p>I have 3 table, <code>Documents</code>, <code>SR</code> and <code>events</code></p>
  
  <p>In <code>documents</code> I am saving all documents related to SR and Events.</p>
  
  <p>And I want to show all documents in one page.</p>
  
  <p>So I am using this select query</p>
  
  <pre><code>Select * 
  from documents d, SR s, Events e 
  where d.relationid = ( case d.documenttype when 'SR' the s.SRId else 'e.eventid end) 
  </code></pre>
  
  <p>but it's not working.</p>
  
  <p>My <code>document</code> table structure is like this :</p>
  
  <pre><code>documentid int, 
  documenttype nvarchar(50),
  relationid int,
  document image,
  docdate date
  </code></pre>
  
  <p>Can anyone please point me to my mistake ?</p>
  
  <p>I want to select all documents with related info. means if its SR document than SR details should display otherwise Events. There is only 2 types of documents right now.</p>
  
  <p>What should be my select query for this ?</p>