title: How to convert a string to integer in SQL Server 2008?
body: <p>I am being challenged by SQL Server. I have this simple query</p>
  
  <pre><code>SELET * 
  FROM mytable
  WHERE ISNUMERIC(propertyvalue) = 1 
    AND CONVERT(int, CONVERT(decimal(9, 0), ISNULL(propertyvalue, 0 ))) &gt; 0 
  </code></pre>
  
  <p>I tried to change the conversion line from</p>
  
  <pre><code>CONVERT(decimal(9, 0), ISNULL(propertyvalue, 0))
  </code></pre>
  
  <p>to</p>
  
  <pre><code>CONVERT(decimal(9, 2), ISNULL(propertyvalue, 0))
  </code></pre>
  
  <p>or </p>
  
  <pre><code>CAST(ISNULL(propertyvalue, 0) AS numeric)
  </code></pre>
  
  <p>none of what I am trying is working what so ever. I keep getting this error</p>
  
  <blockquote>
    <p>Msg 8114, Level 16, State 5, Line 1<br>
    Error converting data type varchar to numeric.</p>
  </blockquote>
  
  <p>Any ideas on how to solve this problem?</p>
  
  <p>EDITED</p>
  
  <p>The propertyvalue has the type of <code>varchar(255)</code> and it has data like</p>
  
  <pre><code>2
  1.5
  2.1
  String
  1String 456
  </code></pre>