Perform replacement on SQL statement