Abu Hurairah reported,

The Messenger of Allah ﷺ said, "Two women went out, each with her child. A wolf attacked one of them and carried off her son. The two then began disputing over the remaining child, and they brought their case to Dawud عليه السلام, who ruled that the child belonged to the elder of the two.They then passed by Sulayman, who asked, 'What is your situation?'They told him the story.He said, 'Bring me a knife, and I will cut the boy in half between you.'The younger woman said, 'Would you really cut him?'He replied, 'Yes.'She said, 'Do not do it. My share of him is hers.'He said, 'He is your son,' and ruled that the child belonged to her."

Nasai 5405

Sahih

أخبرنا الربيع بن سليمان قال حدثنا شعيب بن الليث قال حدثنا الليث عن ابن عجلان عن أبي الزناد عن الأعرج

عن أبي هريرة

عن رسول الله ﷺ أنه قال خرجت امرأتان معهما صبيان لهما فعدا الذئب على إحداهما فأخذ ولدها فأصبحتا تختصمان في الصبي الباقي إلى داود عليه السلام فقضى به للكبرى منهما فمرتا على سليمان فقال كيف أمركما فقصتا عليه فقال ائتوني بالسكين أشق الغلام بينهما فقالت الصغرى أتشقه قال نعم فقالت لا تفعل حظي منه لها قال هو ابنك فقضى به لها

النسائي 5405صحيح
Contents
Reference
Commentary
Ayat
Collection
Sunan Nasai Sughra
Book
Etiquette of judges
Chapter
Permissibility for the ruler to say "do" regarding something he will not carry out in order to reveal the truth
Numbering
Darussalam 5405
Nasai 5405