كتاب المساقاة
22  
The Book of Musaqah
(10)
Chapter: The command to kill dogs, and its abrogation. The prohibition of keeping dogs, except for hunting, farming, (herding) livestock and the like
(10)
بَاب الْأَمْرِ بِقَتْلِ الْكِلَابِ وَبَيَانِ نَسْخِهِ وَبَيَانِ تَحْرِيمِ اقْتِنَائِهَا إِلَّا لِصَيْدٍ أَوْ زَرْعٍ أَوْ مَاشِيَةٍ وَنَحْوِ ذَلِكَ
Sahih Muslim 1575 c

Abu Huraira (Allah be pleased with him) reported Allah's Messenger (ﷺ) as saying:

He who kept a dog would lose out of his deeds equal to one qirat every day. except (one kept) for watching the field or herd.
حَدَّثَنِي زُهَيْرُ بْنُ حَرْبٍ، حَدَّثَنَا إِسْمَاعِيلُ بْنُ إِبْرَاهِيمَ، حَدَّثَنَا هِشَامٌ الدَّسْتَوَائِيُّ، حَدَّثَنَا يَحْيَى بْنُ أَبِي كَثِيرٍ، عَنْ أَبِي سَلَمَةَ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ مَنْ أَمْسَكَ كَلْبًا فَإِنَّهُ يَنْقُصُ مِنْ عَمَلِهِ كُلَّ يَوْمٍ قِيرَاطٌ إِلاَّ كَلْبَ حَرْثٍ أَوْ مَاشِيَةٍ‏"‏ ‏.‏
Reference : Sahih Muslim 1575c
In-book reference : Book 22, Hadith 71
USC-MSA web (English) reference : Book 10, Hadith 3824
  (deprecated numbering scheme)