Error ;Invalid length parameter passed to the RIGHT function.

  • sELECT CASE WHEN first_Name

    Like 'MR.%'THEN

    Right(First_Name,Len(First_Name)-4)

    ELSE

    Right(First_Name,Len(First_Name)-3)

    END nn

    FROM tblCust

    Msg 536, Level 16, State 2, Line 1

    Invalid length parameter passed to the RIGHT function.

  • Your name must have less then 4 characters? This is why Len returns less then 4, then substract 4, and send to the right function, it says invalid parameter, since it wants a positive number...

    Cheers,

    J-F

  • Can you showe me how to do it please. Thank you

  • sELECT CASE WHEN first_Name

    Like 'MR.%'THEN

    Right(First_Name,Len(First_Name)-4)

    ELSE

    Right(First_Name,Len(First_Name)-3)

    END nn

    FROM tblCust

    WHERE Len(First_Name) >= 4

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you

Viewing 5 posts - 1 through 4 (of 4 total)

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