• Remove whitespace before calling the function. Use SUBSTITUTE

    If you uncomment this code it would return null:

    --IF @encoded_text COLLATE LATIN1_GENERAL_BIN

    -- LIKE '%[^ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=]%'

    -- COLLATE LATIN1_GENERAL_BIN

    -- RETURN NULL

    try:

    SET @encoded_text = SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(

    @encoded_text, ' ',''),CHAR(9),''),CHAR(10),''),CHAR(13),'')

    (Okay so 5 years for me to bother to check the discussion is a bit long. I use Oracle lately...)