I have discovered a bug that exists in both SQL 2008 SP2 and SQL 2012 SP1 T-SQL.
SELECT '000' + cast( cast('010' as int)-1 as char(3) ) AS NewSeq -- Correctly Results in 0009
SELECT RIGHT('000' + cast( cast('010' as int)-1 as char(3) ), 3) AS NewSeq -- INCORRECTLY Results in 9. It should be 009
SELECT RIGHT('000' + Convert(char(3), cast('010' as int)-1 ), 3) AS NewSeq -- INCORRECTLY Results in 9. It should be 009
SELECT SubString( '000' + cast( cast('010' as int)-1 as char(3) ), 2, 3 ) AS NewSeq -- Correctly Results in 009
SELECT SubString( '000' + Convert(char(3), cast('010' as int)-1 ), 2, 3 ) AS NewSeq -- Correctly Results in 009
SELECT SubString(RTRIM(CAST('000' + Convert(char(3), cast('010' as int)-1 ) as char(6))), 2, 3) AS NewSeq -- Correctly Results in 009
SELECT RIGHT( RTRIM(CAST('000' + Convert(char(3), cast('010' as int)-1 ) as char(6))), 3) AS NewSeq -- CORRECTLY Results in 009
SELECT RIGHT('000' + '009', 3) AS NewSeq -- Correctly Results in 009