Sunan Ibn Majah, Hadith 1547 ⓘ
It was narrated from Sulaiman bin Buraidah that his father said: “The Messenger of Allah used to teach them, when they went out to the graveyard, to say: As-salamu ‘alaykum ahlad-diyar minal-mu’minina wal- muslimin, wa inna insha’ Allah bikum lahiqun, nas’alul-laha lana wa lakumul-‘afiyah (Peace be upon you, O inhabitants of the abodes, believers and Muslims, and we will join you soon if Allah wills. We ask Allah for well-being for us and for you).’”
حَدَّثَنَا مُحَمَّدُ بْنُ عَبَّادِ بْنِ آدَمَ، حَدَّثَنَا أَبُو أَحْمَدَ، حَدَّثَنَا سُفْيَانُ، عَنْ عَلْقَمَةَ بْنِ مَرْثَدٍ، عَنْ سُلَيْمَانَ بْنِ بُرَيْدَةَ، عَنْ أَبِيهِ، قَالَ كَانَ رَسُولُ اللَّهِ ـ صلى الله عليه وسلم ـ يُعَلِّمُهُمْ إِذَا خَرَجُوا إِلَى الْمَقَابِرِ كَانَ قَائِلُهُمْ يَقُولُ السَّلاَمُ عَلَيْكُمْ أَهْلَ الدِّيَارِ مِنَ الْمُؤْمِنِينَ وَالْمُسْلِمِينَ وَإِنَّا إِنْ شَاءَ اللَّهُ بِكُمْ لاَحِقُونَ نَسْأَلُ اللَّهَ لَنَا وَلَكُمُ الْعَافِيَةَ .
also referenced under: Book 6, Hadith 1614 (In-Book) & Volume 2, Book 6, Hadith 1547 (DarusSalam)