Sahih Bukhari Volume 008, Book 075, Hadith Number 391.

Narated By Jabir : The Prophet used to teach us the Istikhara for each and every matter as he used to teach us the Suras from the Holy Qur'an. (He used to say), "If anyone of you intends to do something, he should offer a two-Rak'at prayer other than the obligatory prayer, and then say: 'Allahumma inni astakhiruka bi'ilmika, wa astaqdiruka biqudratika, wa as'aluka min fadlika-l-'azim, fa innaka taqdiru wala aqdiru, wa ta'lamu wala a'lamu, wa anta'allamu-l-ghuyub. Allahumma in kunta ta'lamu anna hadha-lamra khairun li fi dini wa ma'ashi wa 'aqibati amri (or said, fi 'ajili amri wa ajilihi) fa-qdurhu li, Wa in junta ta'lamu anna ha-dha-l-amra sharrun li fi dini wa ma'ashi wa 'aqibati amri (or said, fi ajili amri wa ajilihi) fasrifhu 'anni was-rifni 'anhu wa aqdur li alkhaira haithu kana, thumma Raddani bihi," Then he should mention his matter (need).