David McGarva, 36, pleaded guilty to the offence which happened in High Street, Peebles, on September 13 last year.
He also admitted assaulting a man in the woman's company by seizing him by the body and attempting to punch him.
Procurator fiscal Alasdair Fay said the accused entered the Crown Hotel and asked if he could purchase a takeaway.
He purchased a pint of lager and sat down, but later stumbled into a customer and was unsteady on his feet and was told to leave.
While outside he moved a beer keg from where it had been sitting and a staff person noticed it had been moved and moved it back.
Mr Fay said that McGarva said something to the female member of staff which she could not understand.
He added McGarva was still outside at five to midnight when the staff member came outside and he picked up the beer keg above his head and threw it at the woman, striking her on the shoulder to her injury.
McGarva then got hold of a man who had intervened by the body and swung a couple of punches at him which missed.
Not guilty pleas to possession of an offensive weapon and culpable and reckless conduct were accepted by the Crown.
Sheriff Peter Paterson said that given the nature of the offence he would be calling for background reports and deferred sentence until July 11.