Data from a Freedom of Information (FOI) request shows that in the 2012-13 period, 13 primary schools did not meet the required standard, climbing to 19 in 2016-17 and 21 over the last year.
Furthermore, from 2017 to April 17 2018, 12 out of 14 of the Scottish secondary schools inspected did not meet nutrient and food and drink standards.
For this time period, 57% of Scottish primary schools and secondary schools combined were not passed by inspectors.
Chair of the British Medical Association Scotland, Dr Peter Bennie, said: "The dietary habits that people pick up in childhood can often stay with us for life, so it is essential that the meals children eat are healthy and nutritious.
"School meals are the best opportunity that local authorities have to directly influence the diet of children, so there is no excuse for failing to provide good quality meals that help to support children's healthy growth."
The number of secondary schools meeting the required standard is currently at the lowest it has been for the last six years, save for 2015-16 when there were also only two that passed.
Reasons for schools not fully meeting food regulations included: school-run tuck shops selling cereal bars that are not permitted, school vending machines selling crisps that don't meet the specific criteria and school lunch menus not providing an oily fish dish as frequently as required.