Aim The aim of this study was to assess the recent time trends of oesophageal disorders, nonulcer dyspepsia, gastric and duodenal ulcer in the light of such risk factors as age, sex, deprivation and urban versus rural residence. Methods The Scottish National Health Service provided diagnostic data on all admissions to all Scottish hospitals from 1981 to 2004 and patient visits to general practitioners (GP) from 1998 to 2004. Results In the last quarter of a century in Scotland, there were sevenfold increases in annual hospitalizations for dyspepsia (from 900 to 6000 per million population) and for oesophageal disorders (from 500 to 3700). Annual hospitalisations for gastric and duodenal ulcer changed from 590 to 1100 and from 1400 to 1130 per million population, respectively. The variation of hospital admissions for dyspepsia among various Scottish regions closely matched the variation of deprivation among them. GP contacts for dyspepsia (27600 per million population) and oesophageal disorders (10000) were common compared with relatively infrequent contacts for gastric ulcer (500) and duodenal ulcer (11200). Dyspepsia showed a rise of GP contacts with increasing scores of deprivation. This rise occurred similarly among urban and rural residents and applied to data for each individual year between 1998 until 2004. None of the other diagnoses showed any clear-cut correlation with grade of deprivation. Conclusion Gastric and duodenal ulcer are relatively rare causes for hospital admission as well as outpatient physician visits. Their former predominant role in upper gastrointestinal disease has been replaced by gastro-oesophageal reflux disease and nonulcer dyspepsia, both increasing sevenfold in the last quarter of a century.