Fix SQL generation

Sometimes the movedColumns-variable contains duplicate columns which results in an incorrect SQL statement.