Dentists are being billed by the Scottish Government for up to £25,000 in backdated fees after an NHS computer glitch led thousands of patients' records to be wrongly duplicated.

More than 2000 have been hit by demands to repay some £3.4 million in the overpayments dating back seven years.

The problem, which does not affect private practices, dates back to the introduction of a new computer records system rolled out to health service dental practices across Scotland in 2006.

The new system of continuous registration replaced the previous system which saw patients' records lapse every two years, automatically clearing out the details of anyone who had not used a practice in the previous 24 months.

It means a patient registered in Glasgow who then moved to Oban could have been registered at two separate practices. Dentists receive a fee, known as registration, capitation and continuing care (RCC) payments, for each person on their books.

The Scottish Government has sent letters to 2131 NHS dentists north of the Border in an effort to claw back the overpayments in the face of calls for the British Dental Association Scotland [BDA] to be written off.

Pat Kilpatrick, Director of BDA Scotland added: "These fees have been invested in equipment, in new staff, new chairs, hiring a dental hygienist. It's been invested in the practice, so it's not as if it's readily available.

"There's a lot of practices that are on the edge of financial sustainability in Scotland. This is worrying enough, but it might tip some of them into not being financially viable, all because the Government never invested in a proper IT system in the first place.

"There should have been unique patient identifiers, the way we have in General Practice."

Although "exercises" have been carried out to withdraw patients from lists where they are duplicated, or have died or left the country, such records are still possible.

NHS Practitioner Services in its letter explained the payment clawback to dentists.

It said: "New daily or monthly controls have been in place since January 2012 to contain the ­potential overpayment within a tolerance level which is broadly commensurate with that accepted in the pre-April 2006 system."

The Scottish Government first became aware of the problem in 2010, but did not alert Practitioner Services and Counter-fraud - the payment arm of primary care in Scotland - to launch recovery proceedings until 2012. Since then they have faced fierce opposition from the BDA.

A debacle involving an ­abandoned NHS patient record south of the Border is estimated to have cost the taxpayer almost £10 billion. MPs have said the failure of the National Programme is the "biggest failure ever seen".

A government spokesman said: "Practitioner Services has a legal requirement to recover over-payments. The process of recovering arrears is a key element of the pay deal for 2013/14 and has been accepted by BDA Scotland and the Scottish Dental Practitioner Committee 'in full and without caveat'.

"The recovery process by ­Practitioner Services equates to £3.4m and applies to practicing dentists only. However, this figure is less than the total dentists will receive in payments this year.

"As well as receiving backdated payments worth £3.2m, as part of the 2013/14 pay deal, they are also receiving a pay award which ­delivers a 2.51% increase in item of service fees. The pay deal is worth an additional £5.2m per annum which the Scottish Government considers to be very competitive in the current economic climate."

A spokesman for NHS National Services Scotland said: "As a public service body, we are required to seek value-for-money for the taxpayer.

"We have been working with the BDA over a long period to address the issue of historic overpayments being made to certain dentists, and we are obliged under regulations to recover all overpayments unless directed otherwise."