كتاب الأيمان
27  
The Book of Oaths
(5)
Chapter: Saying: "If Allah wills" when swearing oaths and at other times
(5)
باب الاِسْتِثْنَاءِ ‏‏
Sahih Muslim 1654 d

Abu Huraira reported that Sulaiman b. Dawud said:

I will certainly have intercourse with seventy wives during the night, and every wife amongst them will give birth to a child, who will fight in the cause of Allah. It was said to him: Say:" Insha' Allah" (God willing), but he did not say so and forgot it. He went round them but none of them give birth to a child except one woman and that too was an incomplete person. Upon this Allah's Messenger (ﷺ) said: If he had said" Insha' Allah." he would not have failed, and his desire must have been fulfilled.
وَحَدَّثَنَا عَبْدُ بْنُ حُمَيْدٍ، أَخْبَرَنَا عَبْدُ الرَّزَّاقِ بْنُ هَمَّامٍ، أَخْبَرَنَا مَعْمَرٌ، عَنِ ابْنِ طَاوُسٍ، عَنْ أَبِيهِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ سُلَيْمَانُ بْنُ دَاوُدَ لأُطِيفَنَّ اللَّيْلَةَ عَلَى سَبْعِينَ امْرَأَةً تَلِدُ كُلُّ امْرَأَةٍ مِنْهُنَّ غُلاَمًا يُقَاتِلُ فِي سَبِيلِ اللَّهِ ‏.‏ فَقِيلَ لَهُ قُلْ إِنْ شَاءَ اللَّهُ ‏.‏ فَلَمْ يَقُلْ ‏.‏ فَأَطَافَ بِهِنَّ فَلَمْ تَلِدْ مِنْهُنَّ إِلاَّ امْرَأَةٌ وَاحِدَةٌ نِصْفَ إِنْسَانٍ ‏.‏ قَالَ فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ لَوْ قَالَ إِنْ شَاءَ اللَّهُ ‏.‏ لَمْ يَحْنَثْ وَكَانَ دَرَكًا لِحَاجَتِهِ ‏"‏ ‏.‏
Reference : Sahih Muslim 1654d
In-book reference : Book 27, Hadith 35
USC-MSA web (English) reference : Book 15, Hadith 4069
  (deprecated numbering scheme)