title: SQL incrementing limit
body: <pre><code>DECLARE @AbbrvCount INT    
  DECLARE @Abbreviation NVARCHAR(50)
  
  SET @Abbreviation = 'PHMY'
  SET @AbbrvCount = (2+ LEN(@Abbreviation)+ 1)    
  
  DECLARE @CDCode NVARCHAR(50)
  
  SET @CDCode = (SELECT CONCAT('CD', @Abbreviation, ISNULL((SELECT TOP 1 SUBSTRING(CashierDepositCode, @AbbrvCount, 50 - @AbbrvCount)
                 FROM CashierDepositSlips
                 WHERE SUBSTRING(CashierDepositCode, 3, LEN(@Abbreviation)) = @Abbreviation
                 ORDER BY CashierDepositCode DESC) + 1, '1')))
  </code></pre>
  
  <p>I'm am having problem when my <code>@CDCode</code> reaches <code>"CDPHMY10"</code>, it doesn't increment any more. Help would be appreciated. I want to increment it to <code>"CDPHMY11"</code> and so on..  Thanks </p>