• Welsh Corgi, thanks for the suggestion. I am reluctant to change to the insert-into method because I think it will take longer overall.

    Sean, thanks for the reply. I already knew what you were saying. I'm really interested in knowing whether the function I wrote can return a string that is sized depending on what the input is. If not, then I'll live with ugly code.

    Ideally, the function would work like this:

    select

    xyz.fLeft_Pad('0', Str(123456789), 9) as [Zip Code1],

    xyz.fLeft_Pad(' ', 'foobar', 6) as [foobar]

    ...with the function returninig a varchar(9) for the first one and varchar(6) for the second.

    Thanks,