I am trying to retrieve the largest number from a varchar column that includes both numbers and strings. An example of the data I\'m working with:
BoxNumber
These answers are only half right. They succeed in isolating numeric values, but don't realize that when the underlying field is a number the Max function evaluates as characters (regardless of casting), reading left to right, so that 789 > 1000 because 7 > 1. A way around this might be to forget about casting and left pad the numbers with zeros to a common length, when Max in character mode should work.