David Burns (27) was carrying a partially concealed knife when he told a shop worker to give him money.

But he had "a change of heart" when this woman's manager came out to the counter. He told the manager that he was joking about the knife and that he just wanted to buy cigarettes.

Detective Sergeant Brendan Bergin told Maurice Coffey, prosecuting, that the owner stood up to Burns and told him to get out of the shop.

She told him he could buy cigarettes in the nearby Lord Mayor's Pub in Swords.

When Burns left, the manager rang gardai and Burns was arrested shortly afterwards as he was leaving that pub with a six pack of beer which he hadn't paid for.

Drunk

The court heard that Burns, of Maple House, North Circular Road, couldn't be interviewed immediately because he was drunk.

He pleaded guilty at Dublin Circuit Criminal Court to attempted robbery of the Spar Shop, Swords on October 29, 2011.

He has 53 previous convictions including assault causing harm, criminal damage, possession of firearms and public order offences.

Judge Mary Ellen Ring had adjourned the case last October to allow for the preparation of a probation report after she said she was concerned that this offence took place not long after Burns had being released from prison for another offence.

She said it was difficult enough to work in some of the late night shops in the city and to have anyone coming into the shop with a weapon was deeply upsetting.

"It can cause people, who need the money, to be too upset to return to work," the judge said before she told Burns it was "make or break time".

She noted there was a positive probation report before the court and that Burns had not come to garda attention in the meantime.

Judge Ring ordered Burns to carry out 200 hours' community service work in lieu of a two-year jail term.

"You are old enough to know better," she said.

Judge Ring warned Burns that if he got into trouble again he would be leaving court in the company of a prison officer.