Michael Brookes, of no fixed abode, had been banned from attending or staying at Pinderfields Hospital last year unless he was taken there in a genuine medical emergency.
It followed "persistent" and "aggressive" anti-social behaviour by Brookes at the hospital, and refusing to leave when NHS staff asked him to do so.
However, despite being given a criminal behaviour order, Brookes continued to attend Pinderfields on several occasions, verbally abuse staff and urinate on the floor when police were called.
He was sentenced to 21 days in prison at Leeds Magistrates Court on July 8, after pleading guilty to breaching his criminal behaviour order.
The police said that NHS employees should not have to put up with abuse.
Inspector Helen Brear, of the Wakefield Central Neighbourhood Policing Team, said: "We welcome this conviction which again demonstrates that criminal behaviour orders do work and give us the power to take real action against those who think it is acceptable to behave in a way which is clearly completely unacceptable to those around them.
"Members of the emergency services who work to help others at a time when they are in real need deserve to be treated with utmost respect and we will not hesitate to support our colleagues in other blue light services."
Evidence gathered by Wakefield Council's anti-social behaviour team helped lead to the prosecution against Brookes.
Councillor Maureen Cummings, portfolio holder for neighbourhoods and communities, said: "It must be clear to everyone that staff and patients in our local hospital should always be treated with respect.
"The magistrates’ decision sends out a message that breaches of criminal behaviour orders are taken very seriously and we will never tolerate aggressive behaviour in our district."
The Mid Yorkshire Hospitals NHS Trust, which runs the hospital, offered their thanks to the police and council for their efforts in bringing the case to court.
David Melia, the organisation's director of nursing and quality said: "Any type of violence against our staff is taken very seriously and we will always seek totake appropriate legal action against offending individuals.
"Our staff are here to care and support very ill people under challenging circumstances.
"We simply will not tolerate any aggressive or disruptive behaviour towards our staff.
"We would like to thank the Wakefield central neighbourhood policing team and Wakefield Council’s anti-social behaviour team for their efforts leading to this conviction."
Local Democracy Reporting Service