This one came to mind a few days ago. I remember several details, but not the title. The primary character is a demon. He's in some sort of contest that involves setting up a fairy tale and then making it have a bad ending. I think that, at the very beginning, there's an archaeological dig where either this demon or another gets released. They were digging up coins and there was a discussion of how writing on ruins is almost always lewd graffiti. An older male professor gets infected, I think while trying to seduce one of the co-eds on the trip. I don't remember what relevance he has to the main plot.
During that main plot, the demon is bringing up the princess and trying to crunch costs. He's having budget issues and keeps having to economize on aspects of the tale. I want to say that he wanted an ever-growing forest of thorns around the castle but has to settle for jets of fire. There was also something about having to use a cheaper magic sword. At some point, the princess recognizes the situation with the jets of flame and, remembering the installation, goes for the shutoff valve. At the end of the story, she marries the prince that rescued her, seemingly reaching her happy ending, but it's made clear that the marriage is on rocky grounds. I don't remember if the demon argued that he won after all as a result.
I think I read this as a paperback in the 90s in the United States. I remember the cover as having bright cartoonish colors, but I don't remember the details. I don't remember if it was an established author, but given I cribbed most of my books from my brother at the time, the odds are that it was.