Killing dogs or pigs is not necessary. They should be treated as the other animals.
“Our prophet (p.b.u.h.) ordered some dogs to be killed. There are related narrations in hadith books. However, in some of these narrations, there are expressions that exempt or subsequently ban those dogs to be killed. Consequently, it is understood that this order must be related to dogs that are attacking or having rabies.” (Diyanat Islam Encyclopedia, Art. Dog)
Following information is from annotations of Sahih Muslim:
“According to our scholars, dog is killed if it has rabies. Otherwise, it is not permissible to kill it. In this respect, it is equivalent if the dog is useful or not.
Imam al-Haramayn says: “The order on killing dogs was abrogated (by naskh). It is saheeh that The Messenger of Allah (p.b.u.h.) had once ordered dogs to be killed. But it is also saheeh that he forbade killing them afterwards. Shariah has made decisions based on the details we have given. The Messenger of Allah (p.b.u.h.) had ordered dark black dogs to be killed. It was at the first times of Islam. It has been abrogated by now.”
There is nothing to say after this verification. ” (Ahmed Davudoglu, Sharh of Sahih Muslim, Taharah, explanation of hadith 93 (280).)