Max length allowed for RETURN in a function

  • ALTER FUNCTION dbo.Translate (@Source VARCHAR(8000))

    RETURNS VARCHAR(8000)

    AS

    BEGIN

    -- do something

    -- do more

    --

    -- at last

    RETURN REPLICATE('a', 8000)

    END

    /*

    TESTING:

    SELECT dbo.Translate('blah')

    Output:

    aaaaaaaaaa..... 256 times

    */

    Output value has length of 256, even though REPLICATE 8000 is used..... why? I am I missing something. Please help.

  • oops..!!

    The problem is not with the function, but with my SSMS. The default value for column length is set to 256.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply