Language:
كتاب الجهاد والسير
56  
Fighting for the Cause of Allah (Jihaad)
(23)
Chapter: Who wishes to beget a son to send for Jihad
(23)
باب مَنْ طَلَبَ الْوَلَدَ لِلْجِهَادِ
Sahih al-Bukhari 2819

Narrated Abu Huraira:

Allah's Messenger (ﷺ) said, "Once Solomon, son of David said, '(By Allah) Tonight I will have sexual intercourse with one hundred (or ninety-nine) women each of whom will give birth to a knight who will fight in Allah's Cause.' On that a (i.e. if Allah wills) but he did not say, 'Allah willing.' Therefore only one of those women conceived and gave birth to a half-man. By Him in Whose Hands Muhammad's life is, if he had said, "Allah willing', (he would have begotten sons) all of whom would have been knights striving in Allah's Cause."

وَقَالَ اللَّيْثُ حَدَّثَنِي جَعْفَرُ بْنُ رَبِيعَةَ، عَنْ عَبْدِ الرَّحْمَنِ بْنِ هُرْمُزَ، قَالَ سَمِعْتُ أَبَا هُرَيْرَةَ ـ رضى الله عنه ـ عَنْ رَسُولِ اللَّهِ صلى الله عليه وسلم قَالَ ‏ "‏ قَالَ سُلَيْمَانُ بْنُ دَاوُدَ ـ عَلَيْهِمَا السَّلاَمُ ـ لأَطُوفَنَّ اللَّيْلَةَ عَلَى مِائَةِ امْرَأَةٍ ـ أَوْ تِسْعٍ وَتِسْعِينَ ـ كُلُّهُنَّ يَأْتِي بِفَارِسٍ يُجَاهِدُ فِي سَبِيلِ اللَّهِ، فَقَالَ لَهُ صَاحِبُهُ إِنْ شَاءَ اللَّهُ‏.‏ فَلَمْ يَقُلْ إِنْ شَاءَ اللَّهُ‏.‏ فَلَمْ يَحْمِلْ مِنْهُنَّ إِلاَّ امْرَأَةٌ وَاحِدَةٌ، جَاءَتْ بِشِقِّ رَجُلٍ، وَالَّذِي نَفْسُ مُحَمَّدٍ بِيَدِهِ، لَوْ قَالَ إِنْ شَاءَ اللَّهُ، لَجَاهَدُوا فِي سَبِيلِ اللَّهِ فُرْسَانًا أَجْمَعُونَ ‏"‏‏.‏
Reference : Sahih al-Bukhari 2819
In-book reference : Book 56, Hadith 35
USC-MSA web (English) reference : Vol. 4, Book 52, Hadith 74
  (deprecated numbering scheme)