• whenriksen (12/1/2016)


    Another option:

    SELECT @Dummy = CASE WHEN LEN( Med_Rec_Nbr ) < 7

    THEN RIGHT('000000' + Med_Rec_Nbr,7)

    ELSE Med_Rec_Nbr

    END

    FROM Primary_Summary

    WHERE LEN( Med_Rec_Nbr ) < 7;

    Performance is very close to the other proposals, and it doesn't truncate values longer than 7.

    Why are you using a CASE when you have a WHERE?

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2