“And David’s heart condemned him after he had numbered the people. So David said to the Lord, ‘I have sinned greatly in what I have done; but now, I pray, O Lord, take away the iniquity of Your servant, for I have done very foolishly’” (2 Sam 24:10).
Exodus 30:11-16 could not have been plainer: the half-shekel had to be offered when a census was taken; every soul was precious; God valued each the same; all needed to be redeemed; the true value is established in God’s presence; and kings should not take pride in what belongs to the Lord. But David went ahead anyway.
However, when convicted in the tribunal of his own heart, note his prayer: it was immediate (“after he had numbered the people”), honest (“I have sinned”), accurate (“sinned greatly”), personal (“in what I have done”), specific in its request (“take away the iniquity of your servant”), and sincere (“I have done very foolishly”). There were consequences, but there was also mercy. God hears and restores when we pray like this!