A former detective, who had sex with a woman at a police station after she reported being the victim of a sexual assault, has avoided jail, with a judge allowing him to serve his 20-month sentence in the community under an Intensive Correction Order.

Mark Garner, 50, from the NSW Far North Coast, pleaded guilty to two counts of misconduct in office over the incident at Tweed Heads police station in 2011, in which he had sex with the woman and used his Glock pistol as a sex toy.

Mark Garner. Credit:Channel Nine

The former detective sergeant also accessed police files in an attempt to retrieve a laptop that contained incriminating photos of himself and the woman.

The court has previously heard that Garner and the woman had begun a relationship earlier that year when the woman came to the station to report that she had been sexually assaulted.

In the Downing Centre District Court on February 5, Judge Ross Letherbarrow described the former officer's actions as a "significant error of judgment" and said he had "abused a position of trust in relation to the victim".

Garner was given a 20-month sentence on that date but given the opportunity to demonstrate that he was suitable for an Intensive Correction Order. This is a community-based punishment in which offenders must participate in rehabilitation programs, observe strict curfews, and undergo regular drug and alcohol testing.

On Wednesday, Judge Letherbarrow made the order, meaning that Garner will not have to serve a single day in jail.