Besides doing a Google and Amazon.com search of the subject, is there any other way to know if your book idea has already been published?
You can also check out Publishers Marketplace, which, for $20 a month, is well worth the investment: you'll see which agents are making what deals, which houses are buying what books, etc.
But there's something else I wanted to address with this question. I think that if you're writing non-fiction, let's say you're working on a book on weight loss, it's obviously important to know what competition is out there. I mean, there have been a gajillion books written on this subject and you need to ensure that yours stands out from the pack. In fact, when drafting a book proposal for an agent, you'll actually include a section on the potential competition, so yes, doing some research and seeing that you're not merely duplicating a previously published book is important.
However, with fiction, I'd worry less that your idea has already been sold and focus more on actually writing the best book that you possibly can. As we've discussed before on the blog, there are probably only so many variations on overarching themes in books: reinvention, lost love, death, grief, coming of age, etc. But how you develop these themes, how you expand and play out your plot is as individual as your fingerprint. Just because you see a book about a 28-year old widow has sold on Publishers Marketplace doesn't mean that it will in any way echo your manuscript about a 30-year old widow. See PS I Love You vs. Good Grief. Both deal with losing a spouse, but neither really have anything to do with one another. (Or so I think...I'm just starting PS right now, and it feels like a very different work than GG.) Publishers (or agents) aren't going to turn you down because there's already ONE book out there that might have a similar overall idea behind it as yours. They'll turn it down because of a million other factors: the plot isn't strong enough, the writing isn't strong enough, your characters aren't strong enough. You get the idea.
Just write the best damn book you can. That's really all you can do.
Who disagrees? (I'm sure that some of you do!)