Small Heterodimer Partner (SHP; NR0B2) is an orphan receptor that acts as a transcriptional regulator, controlling various metabolic processes, and is a potential therapeutic target for cancer. Examining the correlation between the expression of NR0B2 and the risk of gastric diseases could open a new path for treatment and drug development. The Gene Expression Omnibus (GEO) database was utilized to explore NR0B2 gene expression profiles in gastric diseases. Co-expressed genes were identified through Weighted Correlation Network Analysis (WGCNA), and GO enrichment was performed to identify potential pathways. The Xcell method was employed to analyze immune infiltration relationships. To determine the potential causal relationship between NR0B2 expression and gastric diseases, we identified six single-nucleotide polymorphisms (SNPs) as a proxy for NR0B2 expression located within 100 kilobases of NR0B2 and which are associated with triglyceride homeostasis and performed drug-target Mendelian randomization (MR). Bioinformatics analysis revealed that NR0B2 expression levels were reduced in gastric cancer and increased in gastritis. GO analysis and Gene Set Enrichment Analysis (GSEA) showed that NR0B2 is widely involved in oxidation-related processes. Immune infiltration analyses found that NR0B2 was associated with Treg. Prognostic analyses showed that a low expression of NR0B2 is a risk factor for the poor prognoses of gastric cancer. MR analyses revealed that NR0B2 expression is associated with a risk of gastric diseases (NR0B2 vs. gastric cancer, p = 0.006, OR: 0.073, 95%CI: 0.011–0.478; NR0B2 vs. gastric ulcer, p = 0.03, OR: 0.991, 95%CI: 0.984–0.999; NR0B2 vs. other gastritis, p = 0.006, OR:3.82, 95%CI: 1.468–9.942). Our study confirms the causal relationship between the expression of NR0B2 and the risk of gastric diseases, and highlights its role in the progression of gastric cancer. The present study opens new avenues for exploring the potential of drugs that either activate or inhibit the NR0B2 receptor in the treatment of gastric diseases.