Sulayman said, "Tonight I will go around to ninety women, and each one will bear a boy who will fight in the cause of Allah."His companion said to him, Sufyan explained that this meant the angel, "Say, 'If Allah wills.'" But he forgot. He went around to all of them, and not one of them bore a child except a single woman, 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 of attaining what he sought."On another occasion he said, the Messenger of Allah ﷺ said, "Had he made the exception."
قال سليمان: لأطوفن الليلة على تسعين امرأة كل تلد غلاما يقاتل في سبيل الله فقال له صاحبه قال سفيان يعني الملك قل إن شاء الله فنسي فطاف بهن فلم تأت امرأة منهن بولد إلا واحدة بشق غلام فقال أبو هريرة يرويه قال: لو قال إن شاء الله لم يحنث وكان دركا له في حاجته وقال مرة قال رسول الله ﷺ لو استثنى.
Bukhari narrated it in the chapter on Kaffarat al-Ayman (6720), and Muslim in the chapter on Ayman and Nudhur (1654:23), both of them through Ibn Uyayna, from Hisham bin Hujayr, from Tawus, from Abu Hurairah, who related it. This is the wording of Bukhari. Muslim's version is similar, except that he said "seventy women" instead of "ninety women." Muslim also attributed the entire hadith to the Prophet ﷺ, unlike Bukhari's version, where, as you can see, the beginning is stopped at the companion while the end is attributed to the Prophet ﷺ.