Investors should rub their hands in glee when the stocks of companies with solid underlying businesses that pay attractive dividends decline sharply. Why? You get an opportunity to buy with great upside potential plus a higher dividend yield.

Start rubbing those hands. Here are two dividend stocks down 38% to 49% that you can buy right now.

1. Digital Realty Trust

Shares of Digital Realty Trust (DLR 0.37%) have fallen 38% so far this year. Investors have been concerned about the impact of rising interest rates and a bleak economic outlook on the data center real estate investment trust (REIT). 

But Digital Realty Trust's business continues to hum along pretty well. The company reported revenue of $1.2 billion in the third quarter of 2022, up 5% on both a year-over-year and sequential basis. Funds from operations increased by nearly 3.4% year over year to $462.3 million.

Granted, Digital Realty has lowered its outlook for full-year 2022. The REIT now expects core funds from operations of $6.70 to $6.75 per share, down from its previous guidance range provided in February of $6.80 to $6.90. However, CEO Bill Stein stated in the company's Q3 call that management expects "the strong secular trends driving demand toward third-party data centers to continue for years to come."

Meanwhile, Digital Realty's dividend yield tops 4.4%. The company has increased its dividend for 17 consecutive years. I fully anticipate that this impressive streak will keep going for a long time to come.

2. Medical Properties Trust

Medical Properties Trust (MPW) (MPT) is another REIT that has seen its share price sink in 2022. The stock has plunged 49%. At one point this summer, MPT's shares were down nearly 60% year to date.

As was the case with Digital Realty, though, MPT's business appears to be in pretty good shape. Normalized funds from operations increased 3.6% year over year in Q3 to $272.3 million.

The prospects for the hospital operators who are MPT's tenants appear to be getting better. Medicare is increasing its reimbursement rates. MPT CEO Ed Aldag said in the Q3 conference call that tenants hope to negotiate even greater reimbursement rates with other payers.

Investors have a lot to like with MPT's dividend. Its yield currently stands at nearly 9.4%. The company has also increased its dividend for eight consecutive years.

A caveat

It's possible that both of these REIT stocks could decline further before they rebound. Digital Realty expects that the macroeconomic uncertainty could cause customers to take longer to make decisions. MPT's Aldag acknowledged that the improved reimbursement scenario for its tenants "may not be immediate."

The Federal Reserve's actions could also weigh on both stocks. Higher interest rates increase the borrowing costs for both Digital Realty and MPT. This makes it more challenging for the two companies to expand. 

Don't expect that Digital Realty and MPT will soar over the next few months. However, patient investors should be able to realize market-beating returns over the long run -- and great dividends along the way.