Fixes sanitizeSQL proc

Resolved an issue where an extra character was being removed. Resolves #6070 and potentially a few other database related issues.