Fix sql error. references #2492