Fixes sanitizeSQL proc

Resolved an issue where an extra character was being removed. Resolves #6070 and potentially a few other database related issues.

Looks like the routine suffered from getting tripped up by copytext's weird end-1 behavior and was stripping two characters instead of just the quote at the end.