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?