SunTrust Banks ( STI) swung to a loss of $164.4 million, or 41 cents a share, in the second quarter on higher credit costs and a large gain in the year-earlier second quarter.

Earnings in the second quarter of 2008 were $530 million, or $1.52 a share, which included a gain on the sale of shares of Coca-Cola ( KO).

The company recorded loan loss provisions of $962.2 million in the second quarter compared with $449 million a year earlier.

Analysts surveyed by Thomson Reuters expected a second-quarter loss of 52 cents a share.