كتاب المساقاة
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 1574 d

Salim b. 'Abdullah reported on the authority of his father that Allah's Messenger (ﷺ) said:

He who kept a dog other than one meant for watching the herd or for hunting would lose every day two qirat of his good deeds. 'Abdullah and Abu Huraira also said: Or dog meant for watching the field.
حَدَّثَنَا يَحْيَى بْنُ يَحْيَى، وَيَحْيَى بْنُ أَيُّوبَ، وَقُتَيْبَةُ، وَابْنُ، حُجْرٍ قَالَ يَحْيَى أَخْبَرَنَا وَقَالَ الآخَرُونَ، حَدَّثَنَا إِسْمَاعِيلُ، عَنْ مُحَمَّدٍ، - وَهُوَ ابْنُ أَبِي حَرْمَلَةَ - عَنْ سَالِمِ بْنِ عَبْدِ، اللَّهِ عَنْ أَبِيهِ، أَنَّ رَسُولَ اللَّهِ صلى الله عليه وسلم قَالَ ‏"‏ مَنِ اقْتَنَى كَلْبًا إِلاَّ كَلْبَ مَاشِيَةٍ أَوْ كَلْبَ صَيْدٍ نَقَصَ مِنْ عَمَلِهِ كُلَّ يَوْمٍ قِيرَاطٌ ‏"‏ ‏.‏ قَالَ عَبْدُ اللَّهِ وَقَالَ أَبُو هُرَيْرَةَ ‏"‏ أَوْ كَلْبَ حَرْثٍ ‏"‏ ‏.‏
Reference : Sahih Muslim 1574d
In-book reference : Book 22, Hadith 65
USC-MSA web (English) reference : Book 10, Hadith 3818
  (deprecated numbering scheme)