Bank of Scotland has been fined £4.2 million by the City regulator for holding inaccurate mortgage records for 250,000 of its customers.
Failures in the bank's systems meant that it relied on incorrect records for "considerable periods of time" between 2004 and last year, the Financial Services Authority (FSA) said.
It said the mistakes stemmed from Bank of Scotland holding two separate systems for its mortgage information which were not properly linked up.
The problems came to light when the bank put a programme in place to correct the fact that some customers of Halifax, which is part of the same banking group, had received potentially confusing information about changes to their mortgage contracts relating to their standard variable rate (SVR), the FSA said.
The regulator discovered that a number of customers had complained on a consumer website that they had been wrongly left out of the programme and had not received any goodwill payments.
The mistakes grew even worse when Bank of Scotland incorrectly got in touch with 33,700 customers who should never have been included in the programme and mistakenly handed out £20.4 million worth of goodwill payments to 22,700 of them.
Tracey McDermott, FSA director of enforcement and financial crime, said: "These mistakes stemmed from the fact that Bank of Scotland had an inadequate mortgage records system, meaning they could not identify which of those 250,000 customers were subject to a cap on their standard variable rate.
"This breach is particularly serious because the inaccuracies built up over a period of seven years. There was no structure in place to identify errors as they occurred and no checking procedures thereafter. In a complicated organisation where several legacy systems exist, firms have to make sure they are synchronised, otherwise it is their customers who suffer."
Bank of Scotland breached the FSA's Principles for Business, which require a firm to organise and control its affairs responsibly and effectively, with adequate risk management systems.
The bank agreed to settle with the FSA at an early stage of the investigation and the FSA said that, without this early settlement and the firm's co-operation, the fine would have been £6 million.