title: select max value from a string column in SQL
body: <p>I have table with a column <code>Order</code> of type <code>varchar</code> as follows</p>
  
  <pre><code>Order
  -----
  Ord-998,
  Ord-999,
  Ord-1000,
  Ord-1001,
  </code></pre>
  
  <p>I want to get the max value as 1001</p>
  
  <p>But when I run this query, I am getting 999 as max value always</p>
  
  <pre><code>select 
      SUBSTRING((select isnull(MAX(OrderNo), '0000000') 
                 from OrderSummary 
                 where OrderNo like 'Ord%'), 5, 10) as [OrderMax]
  </code></pre>
  
  <p>Can anybody provide a solution?</p>