Trim result in function

  • i have this function so thet i could easily get name of countries in english or in german

    CREATE FUNCTION vNationality ( @lang VARCHAR(3) )

    RETURNS @vNationality TABLE

    (

    PK INT,

    FKArea INT,

    Country CHAR(30)

    )

    AS

    BEGIN

    IF @lang = 'ENG'

    INSERT @vNationality

    SELECT PK, FKArea, RTRIM(CountryENG) AS Country

    FROM Nationality

    IF @lang = 'GER'

    INSERT @vNationality

    SELECT PK, FKArea, RTRIM(CountryGER) AS Country

    FROM Nationality

    RETURN

    END

    GO

    but Country field is not trimmed.

    Does enyone have a solution?

  • Try changing

    Country CHAR(30)

    to

    Country VARCHAR(30)

  • Char is for Fixed length, so Trim functions(LTRIM, RTRIM) has no role to play. mbarrentine has given the right suggestion.

    bm21


    bm21

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

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