Different types of medications are effective for treating insomnia. However, many doctors do not recommend relying on prescription sleeping pills for long-term use. It is also important to identify and treat other medical conditions that may be contributing to insomnia, such as depression, breathing problems, and chronic pain.