Is it safe to take sleeping pills while pregnant?

No. It really depends on what kind. Some are relatively safe and nonaddictive. Some are not as safe and potentially addictive.
Yes. I recommend taking Benadryl or tylenol (acetaminophen) pm for sleep aid. There are prescription medications like Ambien that are safe when taken occasionally. Avoiding sleeping late, avoiding napss, increasing your exercise during the daytime and taking a evening walk after dinner often helps more than turning to medication to solve the problem.