Fixing escape characters in SQL Dynamic Query
many changes
Fixing buildQuery