• I always use this this syntax:

    RIGHT('0000000000' + CAST(SomeNumber AS VARCHAR(10)),10)

    Because I didn't know that STR() is also used for formatting, I thought it only converts string to number.