A shopkeeper disarmed and detained a knife-wielding drug addict when she tried to rob his convenience store, York Crown Court heard.
Danielle Thornton, 21, told Adnan Muhiadeen "I need your money out of your till," and showed him her weapon, said Nigel Hamilton, prosecuting.
But the shopkeeper grabbed her arm, put her to the floor, disarmed her as she struggled and called to a customer to ring police.
It was the second time the Baltic Food store on Lowther Street, The Groves, had been targeted by a robber.
"People who go into small shops, armed with weapons to scare and rob shopkeepers must expect to lose their liberty and that will happen in your case," the Recorder of York, Judge Stephen Ashurst told Thornton.
She was starting to cry as she was taken away to serve a two-year prison sentence.
Thornton, of no fixed address, admitted attempted robbery.
Thornton went into the shop which was close to her then home at about 2.30pm on March 3. She waited until the shop was quiet, approached the counter and made her demand, said Mr Hamilton.
Mr Muhiadeen moved aside and took out his mobile phone to capture her on camera.
She told him: "Don't even think of ringing police" and reached across to take the cash, only for Mr Muhiadeen to grab her.
She had wanted the money to pay off heroin and cocaine debts of £500 to £600.
For her, Peter Byrne said the shopkeeper told police afterwards: "It is sad that a young girl would resort to this sort of thing because of drugs."
Thornton had had a difficult childhood when she herself had been the victim of a serious crime.
She had fallen in with the wrong crowd and aged 18 or 19 had formed a relationship with a partner who was a heavy drug taker.
That had led her into taking drugs herself. The relationship had since broken down and the partner was in prison. On their release they would live in separate cities.
The judge took into account Thornton's efforts to kick her drug habit since her arrest.