title: Removing zeros after a dash
body: <p>I have data in a column formatted like: </p>
  
  <pre><code>012345-0001
  001234-0011
  123456-0111
  000012-1234
  </code></pre>
  
  <p>i need a query to return the data like:</p>
  
  <pre><code>012345-1
  001234-11
  123456-111
  000012-1234
  </code></pre>
  
  <p>i have created a function to remove a varying number of leading zeros, but can't figure out how to do it after the dash.</p>
  
  <p>Thanks for any assistance</p>
  
  <p>Function:</p>
  
  <pre><code>DECLARE @Output varchar(8000),  @Value int,  @Input varchar(8000)
      SELECT
         @Value = CASE
                    WHEN @Input LIKE '%[A-Z]%' THEN -1
                    ELSE CONVERT(int, RIGHT([matcode], 4))
                    END
        FROM  matter
        WHERE matcode = @Input
        IF (@Value = -1) SET @Output = @Input
        ELSE IF (@Value BETWEEN 1 AND 999) SET @Output = RIGHT('000' + CONVERT(varchar(3), @Value), 3)
        ELSE IF (@Value BETWEEN 1000 AND 9999) SET @Output = RIGHT('0000' + CONVERT(varchar(4), @Value), 4)
        ELSE SET @Output = @Input
  RETURN @Output
  </code></pre>