Dale Priestley, 36, stabbed a man four times during an altercation outside the Bagshaw Arms in Norton Avenue, Herdings Park just before 9pm on Sunday, June 18 last year.
During a hearing held at Sheffield Crown Court on Thursday, the court was told how in the run-up to the attack Priestly had been speaking to the victim, and his group of friends inside the pub.
"The defendant seemed aggressive, and the group of males effectively encouraged him to leave," said Katherine Goddard, prosecuting.
Priestly, of Forest Lodge, Oughtibridge left the pub and went to his grandparent's house, and disappeared with a kitchen knife after they left the room to make him a drink, the court heard.
Ms Goddard said: "The defendant returned in a taxi, armed with a knife from his grandparents house. The complainant, having known the defendant for a number of years, and having been on good-terms with him, was concerned there would be more trouble.
"He approached the defendant, and tried to persuade him to go away, hoping that the women and children nearby wouldn't be disturbed.
"Almost immediately the complainant felt a blow to the area underneath his left armpit, and saw the defendant had a knife."
The man suffered one stab wound to his left thorax, and three stab wounds to his upper-left arm in the attack, and was kept in hospital for 10-days following the shocking incident.
Priestly pleaded guilty to one count of wounding with intent at an earlier hearing.
Dr William Hayes told the court that Priestly had a diagnosis of schizophrenia and he was of the opinion that the best course of action that the court could take would be to impose a hospital order, under Section 41 of the Mental Health Act.
Section 41 is a restriction order that courts can impose if they believe a defendant poses a risk to the public, but should be in hospital instead of prison.
District Judge, Robert Moore, followed Dr Hayes' recommendation and sentenced Priestly to a hospital order.
He said: "I'm satisfied that what's required is what's called a hospital order."