A state judge ruled Monday that New York Mayor Michael Bloomberg’s ban on servings of sugary drinks larger than 16 ounces was “arbitrary and capricious,” blocking the limits one day before they were to take effect.

The judge argued, convincingly, that loopholes and exceptions in the mayor’s rules would result in uneven enforcement and ultimately defeat their purpose. The ban would have covered some sugary drinks while exempting others and would have applied to restaurants and delis but not convenience stores. The judge also ruled that the limit on cup size by the Board of Health exceeded its authority.

The mayor — who regards the rules as an important part of an effort to improve public health — immediately announced an appeal that is expected to argue that the judge defined the board’s authority too narrowly.

But there are better ways for Bloomberg to use his time and resources to combat obesity. One is to push Gov. Andrew Cuomo and the state legislature to impose a penny-per-ounce tax on sugary drinks. Just as taxes helped cut the use of cigarettes, taxes could help cut the public’s indulgence in high-calorie, giant drinks.

The mayor and his health officials are right to assert that sugary drinks contribute to obesity, a leading cause of diabetes, heart disease and other chronic health problems. And they’ve done a good job of advertising the dangers of these drinks: A particularly powerful ad shows a young man eating 16 packets of sugar, which is the amount in 20 ounces of soda — while others watch in disbelief.

Bloomberg has worked to improve public health on many fronts. Thanks to his efforts, smoking is outlawed in most places, trans fats are banned and calorie counts are now routinely displayed. While we think he should push more schools to offer free healthful breakfasts in classrooms, he has expanded public access to fresh produce in areas where it was in shortly supply.

But the big-drinks ban was ill conceived and poorly constructed from the start.