According to the Islamic reference sites IslamWeb and Dorar.net, this hadith doesn't exist in any of the Sunni hadith books.
However, in his famous book
إحياء علوم الدين (Reviving the knowledge of [Islam] religion), Imam Ghazali does mention the following anecdote, which is almost identical to the text in question:
ويروى أن الله تعالى أوحى إلى دواد عليه السلام: يا داود إنك تريد وأريد, وإنما يكون ما أريد, فإن سلمت لما أريد كفيتك ما تريد, وإن لم تسلم لما أريد أتعبتك فيما تريد, ثم لا يكون إلا ما أريد
Translation mine (so poor translation):
It's narrated that Allah revealed to Dawud (David) (peace be upon him): O' Dawud, you wish one thing and I wish, and what I wish is what happens/occurs. So if you were content with my wish I will grant you what you wish. And if you weren't content with my wish I will tire you with your wish and then only My wish is what happens.
It is important to note that Imam Ghazali never claims in this text that this was a hadith by the Prophet (or even that it was narrated by any of the Sahabah), he merely references it without mentioning any source.
Also important to note is that, whether or not this is an authentic hadith, one absolute truth that it portrays remains valid; nothing happens without the permission of Allah, even those actions of His creation. This very same sentiment is also mentioned in the Qur'an:
وَمَا تَشَاءُونَ إِلَّا أَن يَشَاءَ اللَّهُ ۚ إِنَّ اللَّهَ كَانَ عَلِيمًا حَكِيمًا
Muhsin Khan Translation:
But you cannot will, unless Allah wills. Verily, Allah is Ever All-Knowing, All-Wise.