Even in the toughest of economic environments, large-cap pharmaceutical stocks tend to perform well, thanks to the high margins on their products and the necessity of their use. However, the threat of generic competition can drag down any pharma. But as Merck's (NYSE:MRK) third-quarter results seem to show, it's dealing with that threat superbly.

Sales were flat at $5.4 billion year over year. Usually, an absence of sales growth is nothing to get excited about, but in this case, Merck is coping with an inflow of generic competition for one of its top products. Cholesterol drug Zocor, beset by generic rivals, had a 65% decline in sales, to $371 million for the quarter. Merck and partner Schering-Plough (NYSE:SGP) are trying to shift the cholesterol market away from Zocor and its generic equivalents, and onto the similar drug Vytorin, but it will take time to do so, and even then, Vytorin will face sales pressure from generic Zocor.

Results were mixed for the other three big drugs as well, which collectively account for the lion's share of Merck's revenues. Singulair sales were up 25% worldwide to $868 million, and Cozaar and Hyzaar sales grew 8% to $813 million. But osteoporosis drug Fosamax's sales were down 1% to $771 million, probably because of increased competition from GlaxoSmithKline's (NYSE:GSK) Boniva and other drugs. With the patent expiration of the more than $3-billion-a-year Fosamax coming early in 2008, overall sales growth won't pick up anytime soon for Merck, even if Singulair or Vytorin revenue gains outperform Zocor's sales losses.

On a positive note, Merck received FDA approval to market its novel type 2 diabetes drug, Januvia, just this month. That should hopefully counteract this drag on sales growth. So should meaningful sales of HPV vaccine Gardasil, garnering $70 million for the quarter despite being marketed only since June.

Including charges for defending against Vioxx lawsuits, but excluding restructuring costs, earnings came in at $941 million and $0.51 a share for the quarter, compared to the $1.4 billion Merck earned last year. When discounting Vioxx-related costs, though, the quarter doesn't look so bad.

Vioxx-related costs were up significantly for the quarter, as Merck recorded a charge of $598 million to increase reserves for future legal defense costs related to the drug. In just the first nine months of 2006, defending against the few Vioxx lawsuits to go to court thus far has cost Merck a staggering $325 million. With 23,800 lawsuits pending, these expenses will only increase in the future.

Shares of Merck are up more than 70% compared to its 2006 lows, and it's easy to see in hindsight how cheap Merck shares were when the stock was near its lows and the company had guided for 2006 earnings of $2.48-$2.52 per share. While things look fine with most of the company's products, Vioxx has nonetheless left plenty of risk embedded in Merck's shares. Conservative investors may do best to stay away from Merck until a lower share-price opportunity presents itself, now that shares are no longer sporting such a large Vioxx discount.

GlaxoSmithKline is a Motley Fool Income Investor pick, and Merck was a former selection of that newsletter. To discover our entire portfolio of dynamic dividend payers, try Income Investor free for 30 days.

Fool contributor Brian Lawler does not own shares of any company mentioned in this article. The Fool has a disclosure policy .