BackgroundDue to the coronavirus disease 2019 (COVID‐19) pandemic, cancer screening, diagnosis, and treatment have changed. This study aimed to investigate the impact of severe acute respiratory syndrome coronavirus 2 (SARS‐CoV‐2) infection prior to gastroenterological cancer surgeries on postoperative complications using data from a nationwide database in Japan.MethodsData on patients who underwent surgery for cancer including esophageal, gastric, colon, rectal, liver, and pancreatic cancer between July 1, 2019, and September 300, 2022, from real‐world sources in Japan were analyzed. The association between preoperative SARS‐CoV‐2 infection and short‐term postoperative outcomes was evaluated. A similar analysis stratified according to the interval from SARS‐CoV‐2 infection to surgery (<4 vs. >4 weeks) was conducted.ResultsIn total, 60 604 patients were analyzed, and 227 (0.4%) patients were diagnosed with SARS‐CoV‐2 infection preoperatively. The median interval from SARS‐CoV‐2 infection to surgery was 25 days. Patients diagnosed with SARS‐CoV‐2 infection preoperatively had a significantly higher incidence of pneumonia (odds ratio: 2.05; 95% confidence interval: 1.05–3.74; p = 0.036) than those not diagnosed with SARS‐CoV‐2 infection based on the exact logistic regression analysis adjusted for the characteristics of the patients. A similar finding was observed in patients who had SARS‐CoV‐2 infection <4 weeks before surgery.ConclusionsPatients with a history of SARS‐CoV‐2 infection had a significantly higher incidence of pneumonia. This finding can be particularly valuable for countries that have implemented strict regulations in response to the COVID‐19 pandemic and have lower SARS‐CoV‐2 infection‐related mortality rates.