Assessing the relative effectiveness and safety of additional treatments when metformin monotherapy is insufficient remains a limiting factor in improving treatment choices in type 2 diabetes. To determine whether data from electronic health records across the University of California Health system could be used to assess the comparative effectiveness and safety associated with 4 treatments in diabetes when added to metformin monotherapy. This multicenter, new user, multidimensional propensity score-matched retrospective cohort study with leave-one-medical-center-out (LOMCO) sensitivity analysis used principles of emulating target trial. Participants included patients with diabetes receiving metformin who were then additionally prescribed either a sulfonylurea, dipeptidyl peptidase-4 inhibitor (DPP4I), sodium-glucose cotransporter-2 inhibitor (SGLT2I), or glucagon-like peptide-1 receptor agonist (GLP1RA) for the first time and followed-up over a 5-year monitoring period. Data were analyzed between January 2022 and April 2023. Treatment with sulfonylurea, DPP4I, SGLT2I, or GLP1RA added to metformin monotherapy. The main effectiveness outcome was the ability of patients to maintain glycemic control, represented as time to metabolic failure (hemoglobin A1c [HbA1c] ≥7.0%). A secondary effectiveness outcome was assessed by monitoring time to new incidence of any of 28 adverse outcomes, including diabetes-related complications while treated with the assigned drug. Sensitivity analysis included LOMCO. This cohort study included 31 852 patients (16 635 [52.2%] male; mean [SD] age, 61.4 [12.6] years) who were new users of diabetes treatments added on to metformin monotherapy. Compared with sulfonylurea in random-effect meta-analysis, treatment with SGLT2I (summary hazard ratio [sHR], 0.75 [95% CI, 0.69-0.83]; I2 = 37.5%), DPP4I (sHR, 0.79 [95% CI, 0.75-0.84]; I2 = 0%), GLP1RA (sHR, 0.62 [95% CI, 0.57-0.68]; I2 = 23.6%) were effective in glycemic control; findings from LOMCO sensitivity analysis were similar. Treatment with SGLT2I showed no significant difference in effectiveness compared with GLP1RA (sHR, 1.26 [95% CI, 1.12-1.42]; I2 = 47.3%; no LOMCO) or DPP4I (sHR, 0.97 [95% CI, 0.90-1.04]; I2 = 0%). Patients treated with DPP4I and SGLT2I had fewer cardiovascular events compared with those treated with sulfonylurea (DPP4I: sHR, 0.84 [95% CI, 0.74-0.96]; I2 = 0%; SGLT2I: sHR, 0.78 [95% CI, 0.62-0.98]; I2 = 0%). Patients treated with a GLP1RA or SGLT2I were less likely to develop chronic kidney disease (GLP1RA: sHR, 0.75 [95% CI 0.6-0.94]; I2 = 0%; SGLT2I: sHR, 0.77 [95% CI, 0.61-0.97]; I2 = 0%), kidney failure (GLP1RA: sHR, 0.69 [95% CI, 0.56-0.86]; I2 = 9.1%; SGLT2I: sHR, 0.72 [95% CI, 0.59-0.88]; I2 = 0%), or hypertension (GLP1RA: sHR, 0.82 [95% CI, 0.68-0.97]; I2 = 0%; SGLT2I: sHR, 0.73 [95% CI, 0.58-0.92]; I2 = 38.5%) compared with those treated with a sulfonylurea. Patients treated with an SGLT2I, vs a DPP4I, GLP1RA, or sulfonylurea, were less likely to develop indicators of chronic hepatic dysfunction (sHR vs DPP4I, 0.68 [95% CI, 0.49-0.95]; I2 = 0%; sHR vs GLP1RA, 0.66 [95% CI, 0.48-0.91]; I2 = 0%; sHR vs sulfonylurea, 0.60 [95% CI, 0.44-0.81]; I2 = 0%), and those treated with a DPP4I were less likely to develop new incidence of hypoglycemia (sHR, 0.48 [95% CI, 0.36-0.65]; I2 = 22.7%) compared with those treated with a sulfonylurea. These findings highlight familiar medication patterns, including those mirroring randomized clinical trials, as well as providing new insights underscoring the value of robust clinical data analytics in swiftly generating evidence to help guide treatment choices in diabetes.