title: SQL Server 2005 Convert VARCHAR to INT but default on invalid type
body: <p>I have a varchar(100) column in a table that contains a mix of integers (as strings) and non-integer strings. E.g.</p>
  
  <pre><code>| dimension varchar(100) |
  | '5'                    |
  | '17'                   |
  | '3'                    |
  | 'Pyramids'             |
  | 'Western Bypass'       |
  | '15'                   |
  </code></pre>
  
  <p>How can I write an expression to, e.g. sum up all the values that are valid integers? If I were to try:</p>
  
  <pre><code>-- should return 5 + 17 + 3 + 15 = 40
  SELECT
      SUM( CONVERT( INT, dimension ) )
  FROM
      mytable
  </code></pre>
  
  <p>I would receive a <code>Conversion failed when converting the varchar value 'Pyramids' to data type int.</code> error.</p>
  
  <p>Is there a test I can use in my expression, much like the <code>ISNULL()</code> function, that permits me to specify a default value if the field is not a number?</p>