“All you had to do was walk away.”

That was the message from a Hennepin County judge to Sherman Alexander this week before he sentenced Alexander to 28½ years in prison for a shooting outside a downtown Minneapolis nightclub last fall that left a woman dead and another man wounded. Prosecutors said that both victims were bystanders, caught in the path of bullets intended for someone else.

Had Alexander chosen not to continue a dispute that began inside the club, Jenna Rae Heilman might still be alive, said Judge Juan Hoyos, according to a news release. On Thursday, Alexander, of Brooklyn Center, pleaded guilty to second-degree murder and second-degree assault.

“All you had to do was walk away,” Hoyos said in handing down the sentence. “It was a bar fight. Instead, you got a gun and fired 10 times.”

He sentenced Alexander, 32, to 342 months in prison for the crime. Alexander’s court-appointed attorney didn’t immediately respond Thursday afternoon to an e-mail seeking comment.

Alexander admitted in court Thursday to being out with friends at the Pourhouse Bar, 10 5th St. S., on the morning of Sept. 5, when an acquaintance of his tried to steal a bottle of liquor from another group of people, prosecutors said. A brawl ensued, and someone struck Alexander with a bottle or a glass before bouncers intervened and kicked both groups out of the bar.

Once outside, prosecutors say Alexander beelined to his car to retrieve his gun after spotting one of the men with whom he had fought inside the nightspot. Moments later, he wildly fired 10 shots toward the man, but missed.

Instead, one of the bullets hit Heilman, who had been out belatedly celebrating her 28th birthday with friends, in the left hip. The slug “ricocheted” through her body, damaging several organs and her femoral artery, according to prosecutors. The male victim was struck in his buttocks but survived.

Heilman clung to life for more than a month, enduring 13 surgeries that left her in excruciating pain, relatives said. She died of her injuries on Oct. 29.

Before the sentence was handed down, several of her relatives shared their victim impact statements.

“Jenna was a fighter,” Deborah Heilman said in court of her only child. “She told me she loved me every day.”