Police Scotland has admitted it lost 20,000 stop and search records because "someone pressed the wrong button".
The admission came as senior officers appeared before a Holyrood committee.
Among them was Chief Constable Sir Stephen House, who said he had apologised for giving incorrect information to the police watchdog over stop and search statistics.
It follows controversy over police carrying out "consensual" searches of children.
Assistant Chief Constable Wayne Mawson told MSPs on the Scottish Parliament's justice sub committee that a total of 20,086 stop and search records had been lost because a "computer programmer pressed the wrong button between May and July last year".
How easy is it to lose data?
By Marc Ellison
BBC Scotland data journalist
If today's meeting failed to resolve the stop-search debate, it did at least reveal the smoking gun behind the release of "inaccurate" data - or more accurately, the smoking geek.
Yes, you read that correctly.
Assistant Chief Constable Wayne Mawson told members of the justice committee that 20,086 stop-search records were corrupted last year - because a computer programmer pressed "the wrong button".
Now, as a former computer programmer myself, I question this.
Even if it were that easy to delete thousands of records with one keystroke, most database management systems have a way to retrieve data - and, even if they didn't, why weren't back-ups made?
If there are no back-ups to a system that loses data then my advice would be to mark that pesky keyboard button in red, and encase it in unbreakable glass to avoid any future errors.
He added: "That lost the results data from those records. So they had been properly put on the system by the officers as a result of stopping and searching people, but we lost the outcome of it as a computer programming error.
"We have been working really hard to recover that data. I have personally overseen the sending out of several thousand emails to officers and follow-up audits.
"We have been working hard with HMICS to oversee everything that we do, to make sure it is done properly and I am pleased to say that the vast majority of that data, those results, are now back on the system."
Sir Stephen had earlier told MSPs on the justice sub-committee that he had "made a mistake in the language that I used" to last week's meeting of the Scottish Police Authority (SPA).
But he denied claims that trust in the police had been eroded over the stop and search controversy, and insisted the tactic made Scotland a safer place to live.
Sir Stephen's appearance before the committee came days after he admitted to the police watchdog that statistics his force released to BBC Scotland on stop-and-search were "not 100% accurate" and were "not fit for public consumption".
He also claimed that he had been forced to release the data by the Information Commissioner.
Emails between the commissioner and the police later contradicted this claim, and showed that the information release by the police was voluntary.
BBC Scotland, which was not told that there were concerns over the accuracy of the statistics, reported earlier this month that the police were still stop-searching hundreds of children under 12, despite a commitment to end the tactic.
The figures suggested that 356 children were searched by police after the pledge to end the practice was made.
At last week's special meeting of the Scottish Police Authority, senior officers blamed a "clunky" ICT system and problems with the recording of incidents for inaccuracies in the data they had provided to the BBC.
They said analysis of the figures now suggested that only 18 of the searches had been contrary to force policy.
Justice sub committee member and Liberal Democrat MSP Alison McInnnes put it to the chief constable that Police Scotland's response over the issue had been "incoherent".
She said it was "barely credible" that the police were now only talking about 18 consensual stop-searches rather than 356.
She asked: "What I am trying to understand is, is it incompetence or do you have a disregard for the authority of the Scottish Police Authority? Chief Constable, do you find it a nuisance to have to account for the force's actions to the SPA and to the parliament?"
Sir Stephen responded by saying that he "took very seriously" his duty to account to both the SPA and to the Scottish Parliament and said he had written to the SPA following last week's meeting to clarify some of his comments.
He added: "I don't see anything wrong with, if you make a mistake, acknowledging you made a mistake and apologising to the body you are accountable for that mistake. That is exactly what I did."
Sir Stephen said stop and search was a "complicated matter" and that there were some "training issues" with officers which needed to be addressed.
But he said confidence levels in the police remained "high, in the 80s" and that there had not been a drop as a result of the stop-search controversy.
The chief constable added: "Of course we don't want the sort of headlines we've had but part of the reason for coming here today is to try and address those headlines and try and set the record straight.
"And where we made a mistake - and I've already said it once - we acknowledged that I made a mistake in the language that I used. I shouldn't have used that language."
He also said there had been a 32% drop in the volume of stop of searches so far this year compared to the first year of Police Scotland.
But he accepted there have been huge communication problems between Police Scotland, its officers and the public.
Calum Steele, general secretary of the Scottish Police Federation, told the committee that officers were still under the impression that they must fulfil a target for searching members of the public, despite repeated assurances to the contrary by Sir Stephen.
Police Scotland has generated controversy since its inception on 1 April 2013, beginning with a public power struggle between Sir Stephen and his civilian watchdog, questions over the force's accountability, misunderstandings and inaccurate figures.
There has also been disquiet among some sections of society over armed police, stop and search and the closure of police offices and control rooms.