[sd2_mr0682] Next bunch of SQL fixes.