title: Conversion failed when converting date and/or time from character string
body: <p>I have a fairly simple pagination query used to get rows from a table</p>
  
  <pre><code>ALTER PROCEDURE mytable.[news_editor_paginate]
      @count int,
      @start int,
      @orderby int
  AS
  BEGIN
      SET NOCOUNT ON;
      SELECT TOP (@count) * FROM 
      (  
          SELECT news_edits.*,
          ROW_NUMBER() OVER (
              ORDER BY CASE 
                  WHEN @orderby = 0 THEN news_edits.[time]
                  WHEN @orderby = 1 THEN news_edits.lastedit
                  WHEN @orderby = 2 THEN news_edits.title
                  END
              DESC
          ) AS num
          FROM news_edits
      ) AS a
      WHERE num &gt; @start
  END
  </code></pre>
  
  <p>The <code>@orderby</code> parameter decides which column the results should be ordered by.</p>
  
  <p><code>news_edit.[time]</code> and <code>news_edits.lastedit</code> are both datetime fields. But <code>news_edits.title</code> is a varchar field.</p>
  
  <p>The query runs fine for both the datetime fields but when <code>@orderby = 2</code> I get the following error:</p>
  
  <p><em>"Conversion failed when converting date and/or time from character string."</em></p>
  
  <p>The problem I'm having is that I'm not trying to convert anything?</p>