A Brooklyn detective got blitzed on his way to a robbery investigation Thursday and drunkenly shot his partner in the hand while showing him his old-school six-shooter, police sources said.

With blood all over the front seat, Detective Jay Poggi, a 31-year veteran, drove Matt Sullivan to the hospital despite a blood-alcohol level that allegedly was above the legal limit, the sources said.

The shot cop, who has been on the job 15 years, needed surgery on his wrist, but was in stable condition. Poggi was arrested for DWI.

The detectives had set out from the 75th Precinct in East New York around 1 a.m., telling their bosses they were tracking a robbery suspect in the Rockaways.

But instead of hunting down leads, the detectives stopped off at the Cross Bay Diner in Howard Beach, Queens, where “they sell beer,” a source said.

After downing several drinks, the men went back to their car and Poggi thought it was a good time to show Sullivan the hammer of his throwback .38-caliber Smith and Wesson, according to court papers.

The gun went off, and a bullet hit his partner in the right wrist, sources said.

Poggi drove Sullivan to Jamaica Hospital, where the third-grade detective underwent surgery to remove the bullet from his shooting hand, sources said.

Poggi had bloodshot eyes and his breath smelled of booze, according to court papers.

He blew a .113 — which is above of the legal limit of .008 — during a Breathalyzer test at the hospital around 3:15 a.m., but refused a follow-up exam test from Internal Affairs, which launched an investigation.

The first-grade detective was suspended without pay from his $154,000-a-year job, but released after his arraignment. His driver’s license was suspended.

“What the hell was he thinking?” said one police source about Poggi. “He just threw his whole career away.”

Poggi, who has spent most of his career in East New York, was instrumental in building a case against Lamont Pride — who gunned down another 75th Precinct officer, Peter Figoski, in 2011.

“He’s one of the detectives that helped solve the case and put Figoski’s killer behind bars,” said one police source.

“He knew Pete for years. This is such a shame. He wasn’t thinking. It’s out of character for him.”

Figoski was fatally shot in the face while responding to a “burglary in progress” at an East New York drug den.

Pride and several cohorts were quickly rounded up during a citywide manhunt.