2 Samuel 7:14
12 When the time comes for you to die, I will raise up your descendant, one of your own sons, to succeed you, and I will establish his kingdom. 13 He will build a house for my name, and I will make his dynasty permanent. 14 I will become his father and he will become my son. When he sins, I will correct him with the rod of men and with wounds inflicted by human beings. 15 But my loyal love will not be removed from him as I removed it from Saul, whom I removed from before you.
1 Kings 8:25
24 You have kept your word to your servant, my father David; this very day you have fulfilled what you promised. 25 Now, O Lord, God of Israel, keep the promise you made to your servant, my father David, when you said, ‘You will never fail to have a successor ruling before me on the throne of Israel, provided that your descendants watch their step and serve me as you have done.’ 26 Now, O God of Israel, may the promise you made to your servant, my father David, be realized.
Notes and References
"... Modern investigators were confused over these insertions about the Davidic covenant. Sometimes the insertions reiterated this promise that the Davidic kings would rule forever, even if they sinned; but sometimes they seemed to be saying just the opposite, that the kings could rule only if they did not sin. For example, the covenant promise in 2 Samuel 7 says explicitly that even if the king does wrong he keeps the throne ... But the covenant promise in 1 Kings 8:25 says that the king's tenure on the throne does depend on his behavior: There will not be cut off from you a man before me sitting on the throne of Israel only if your sons keep their way, to go before me as you went before me. How could the Deuteronomist insert lines that blatantly contradicted each other? Was the covenant conditional or unconditional? If we examine all of the passages that mention the Davidic covenant, we will find that all of the conditional passages spoke of the kings' holding the throne of Israel. All of the unconditional passages spoke of the kings' holding the throne. This petty difference of wording was not so petty to the writer. He had to deal with the historical fact that David's family started out ruling the whole united kingdom of Israel, but that they had lost all of it except their own tribe of Judah. He therefore pictured the covenant promise to David to be partly conditional and partly unconditional ..."
Friedman, Richard Elliott Who Wrote the Bible? (p. 133) Harper San Francisco, 1997