What platform is the datalength function valid for?
But that is the correct idea fairly easy, but the performance on a large table would probably have to be a full table scan. (In Oracle you can create function based indexes.)
And depending on the datatype you may have to perform a TRIM...