Surgery is a type of medical treatment where an individual's body was opened and manual and instrumental techniques were used to affect a positive outcome.
Surgery was used to treat pathological conditions or other injuries, improve body functioning, or change a being's appearance for cosmetic or more sinister means.
During the crisis on Tarsus IV, surgeons at the New Anchorage hospital were very busy in performing emergency surgery, to the point that it was difficult for a doctor to be found in the hospital to help treat patients. (DSC novel: Drastic Measures)
In 2256, the Klingon Voq underwent a surgical procedure called choH'a'. This surgical procedure was used to give him the body, personality, and memories of captured Starfleet officer Ash Tyler. Voq's personality was later removed by L'Rell, leaving a new hybrid individual who had the original Tyler's personality with Voq's memories. (DSC episodes: "Despite Yourself", "The Wolf Inside", "Vaulting Ambition", "The War Without, The War Within")
Doctor Leonard McCoy was forced to perform emergency surgery on Sarek when the Vulcan Ambassador suffered a heart attack while en route to Babel. This was the first time that McCoy had performed surgery on a Vulcan. (TOS episode: "Journey to Babel") While suffering from amnesia, the sight of Sarek's son Spock dying on an operating table was enough to bring McCoy out of him amnesiac state, and McCoy successfully completed the operation. Afterwards McCoy grumbled that every time he treated Spock he wondered if he would be able to put him back togther again. (TOS novel: Dreams of the Raven)
After being stabbed through the heart by a Nausicaan in 2327, Jean-Luc Picard underwent emergency surgery to replace his damaged heart with an artificial organ. Picard later underwent surgery to replace that heart with a newer model heart. His heart was damaged in 2369, requiring surgery to repair the damage. (TNG episodes: "Samaritan Snare", "Tapestry")
Despite opposition from Doctor Beverly Crusher, Lieutenant Worf underwent a surgical procedure where a genitronic replicator was used to create a new spine for him after his original spine was broken in an accident. Worf nearly died during the operation, but the redundant nature of Klingon biology enabled him to survive the operation and recover fully from his injuries. (TNG episode: "Ethics")
There was little progress on genitronics over the next decade. (TNG novel: A Time for War, A Time for Peace) However, Dr. Simon Tarses would later adapt the genitronic procedures to repair Ro Laren's spine after it was damaged by the Jem'Hadar observer Taran'atar.
Captain Kira Nerys was also critically injured by Taran'atar. Doctor Bashir was unable to save her heart due to the damage it sustained, and instead performed emergency surgery to replace her heart with an artificial one. (DS9 novel: Warpath)