More error fixes from sql changeover