Abu Hurairah reported,

Sulayman said, "Tonight I will go around to ninety wives, each of whom will bear a boy who will fight in the cause of Allah."His companion (Sufyan said, meaning the angel) said to him, "Say, 'If Allah wills.'"But he forgot, and he went around to them, yet not one of those women bore a child except one, who delivered half a boy.Abu Hurairah, narrating this, said, "Had he said, 'If Allah wills,' he would not have broken his oath, and it would have been a means for him to attain his need."On another occasion he said, the Messenger of Allah ﷺ said, "Had he made the exception."Abu Zinad narrated to us from Araj the like of the hadith of Abu Hurairah.

Bukhari 6720

Sahih

حدثنا علي بن عبد الله حدثنا سفيان عن هشام بن حجير عن طاوس سمع

أبا هريرة قال

قال سليمان لأطوفن الليلة على تسعين امرأة كل تلد غلاما يقاتل في سبيل الله فقال له صاحبه قال سفيان يعني الملك قل إن شاء الله فنسي فطاف بهن فلم تأت امرأة منهن بولد إلا واحدة بشق غلام فقال أبو هريرة يرويه قال لو قال إن شاء الله لم يحنث وكان دركا له في حاجته وقال مرة قال رسول الله ﷺ لو استثنى وحدثنا أبو الزناد عن الأعرج مثل حديث أبي هريرة

البخاري 6720صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Expiations for oaths
Chapter
Exception in oaths
Numbering
Darussalam 6720
Bukhari 6720