Have you tried importing data from an Excel sheet and needed to sort by a field length? I had an extra large set of data with a field full of long strings. One of them exceeded the maximum field length when I tried to import the Excel sheet into SQL.
There is no direct function to sort a list of column by character length, so you need to use a help column to count the number of the strings first, then sort them.
1. Beside the value column, enter this =LEN(A1) formula in a blank cell B1, see screenshot:
2. Then press Enter key and you will get the number of the text string, then select cell B1 and drag the fill handle to the range that you want to contain this formula.
3. All the number of strings in Column A have been extracted in Column B, and then you can sort this range in Column B by clicking Data > Sort, see screenshot:
4. In the Sort Warning prompt box, check Expand the selection option, and then click Sort button.
5. And then in the Sort dialog box, select Column B that you want to sort by, and choose the type that you need to sort on, at last choose the sort order, here we select Values in the Sort On drop-down list and Smallest to Largest in Order drop-down list. See screenshot:
6. Then click OK, and the strings have been sorted by the character length. You can delete the Column B as you need. See screenshot:
That's it! Hope this helps you find a long string on a large dataset.