SQL history fixed