• Just curious, why are you casting your input to a decimal and then to VARCHAR?

    If you're trying to convert a numerical data type to a SSN or tax ID, try the following:

    RIGHT('000000000' + RTRIM(CAST(Tax_id_number AS VARCHAR)), 9)

    Tim Mitchell, Microsoft Data Platform MVP
    Data Warehouse and ETL Consultant
    TimMitchell.net | @Tim_Mitchell | Tyleris.com
    ETL Best Practices