"I was reading my Bible the other day and came across 2nd Samuel 21.19 which says Elhanan killed Goliath the Philistian giant. I though David killed Goliath. Which is it?"
Goliath is mentioned in three passages: 1st Samuel 17, the familiar David and Goliath story; 2nd Samuel 21.19, where the writer says Elhanan killed Goliath; and Goliath is mentioned as well in 1st Chronicles 20.5. In the Chronicles passage it says Elhanan killed Lahmi the brother of Goliath. Three reports, none agreeing, and confusion reigns. Who really killed Goliath?
What you do with these contradictory passages is really determined by your theology of the Bible.
In reality, most people of the faith tend to just ignore the existence of such difficulties, and while that's certainly all right, when one is confronted with a contradiction there's a tendency to become uncomfortable. But in discomfort there is hope for a solution.
There are a number of ways to resolve the conflict between the passages and to get the story couched in a historical context.
One way is to simply add the words, "the brother of Goliath" to the 2nd Samuel passage as the King James Version and the Living Bible do, thus Elhanan killed the brother of Goliath, not Goliath the giant. This solution assumes these words were accidentally omitted from the ancient Hebrew texts as we have them today and need to be added again.
Another way to explain the difference is to suppose David killed an unknown warrior and the writers borrowed the name "Goliath" who was a well known giant of the time.
A third was is to assume that the three different events took place: David slew one giant named Goliath, Elhanan killed another giant named Goliath, and later slew Lahmi as well.
The only problem with this notion is Goliath seems always to be associated with his weighty spear which was "like a weaver's beam" in all three stories, thus narrowing the possibilities of multiple accounts.
There is another solution, though this explanation is dependant upon how one views the Bible.
This solution dictates the Bible as a book of faith filled with accounts of humanity's relationship with God, and God's relationship with us. The many narrative accounts (stories) found in scripture are therefore etiological, that is, they explain origins and sources (and traditions, rituals, and even relationships, etc.) through the use of story. Thus the question, "How did we come into being?" is answered through the two creation accounts (found in Genesis 1.1-2.3 and 2.4-25), the question, "Why did the Israelites worship at Bethel?" is answered through the Jacob's ladder story in Genesis 28, and so on. Each story holds a "truth," an explanation, of some detail of our heritage and our faith. These "truths" may or may not be historical facts, though many are probably based on some historical deed. The David and Goliath story (or the Elhanan and Goliath story) is probably one of these.
David was known as a great warrior of God, a man who trusted in the Lord from his earliest childhood. Indeed, that's the picture we have of David even today; how much more to small nation Israel which was besieged regularly by stronger nations to the north and to the south.
Everyone needs their heros, and David was the hero of Israel. Somewhere, somehow, the story of Goliath was ascribed to David--and why not, he was the greatest king and warrior of Israel.
Of course, the account of Elhanan still stood, perhaps he was the warrior who had actually done the deed. But by the time the Chronicles' passage was written the David and Goliath story was prevalent in the culture, and so they later ascribed the killing of Lahmi to Elhanan instead of Goliath. The Samuel account, however, remained as written, preserving for us today the enigma over the history of the death of Goliath.
Who really killed Goliath? It really doesn't matter. What matters is the etiology, the teaching, of David as a man of faith against unbeatable odds--unbeatable except for his faith and God's aid to the faithful.