It’s quite simple if you’re using MySQL or PostgreSQL – the function you need in both is simply – length()
There are a couple of points you’d better keep in mind if you’re using SQL Server, however.
1. The function in that environment is called len()
2. Unlike length in the other two database systems, len() excludes trailing blanks when counting the characters in a string. If you want them included, you need to use datalength()