As part of debugging a bit of code I needed to know the longest possible field lengths that a record contains. You might need to know this if you are performing a database migration. The following query returns a field, along with the length of the string, and orders the results by the number of characters in that string.
- SELECT FIELD, CHARACTER_LENGTH(FIELD) AS fieldCharacterCount
- FROM TABLE
- ORDER BY fieldCharacterCount DESC