title: How to check if last 4 digits of value is in a range in SQL Server
body: <p>I have a column where each value is 9 characters (col1). I need to pull the last 4 characters of col1 and see if the value is in the range of 0001 - 0879. There could be letters in this string. </p>
  
  <p>Initial table</p>
  
  <pre><code>col1       column2
  585550529  red
  589960MNO  blue
  849828415  green
  </code></pre>
  
  <p>Expected result</p>
  
  <pre><code>col1       column2  column3
  585550529  red      True
  589960MNO  blue     False
  849828415  green    False
  
  SELECT col1, 
         col2, 
         CASE WHEN RIGHT(col1,4) IN('0001','0002','0003') THEN 'true' ELSE 'false' END
  FROM table
  </code></pre>
  
  <p>Is there anyway to do this without having to type all 879 strings within the IN statement? This is going to get ugly.</p>