Midazolam is frequently used (usually in combination with other agents, such as morphine) by anesthesiologists for sedating patients prior to surgery or other invasive medical procedures, such as endoscopy. The patient typically does not actually lose consciousness, but may lose the ability to form memories.