As we typically do not write SQL code in Appian, I do not know of a good way to do that. But I would try to get direct access to the DB and do whatever is necessary.
But you might also try to find out how it came to that situation, and try to prevent it.