(45) باب قَوْلِهِ صلى الله عليه وسلم " إِنَّمَا الأَعْمَالُ بِالنِّيَّةِ." وَأَنَّهُ يَدْخُلُ فِيهِ الْغَزْوُ وَغَيْرُهُ مِنَ الأَعْمَالِ
It has been narrated through a different chain of transmitters on the authority of Sufyan who said that he heard 'Umar b. al-Khattab relate (this tradition) from the Prophet (ﷺ) while he was delivering a sermon from the pulpit. (ES)
Reference (ES): Sahih Muslim 1907 b (ES)
In-book reference (ES): Book 33, Hadith 223 (ES)
USC-MSA web (English) reference(deprecated numbering scheme): Book 20, Hadith 4693 (ES)