#696 cleanup SQL