fixes for mssql and db2 queries