Use of LEN Function in SQL:
(1) “LEN” function is used to calculate the length of the string.
(2) Let’s take an example to calculate the length of “The Universe” as shown.
(3) Select the database in the SQL server and click on the “New Query” button as shown.

(4) After that new query editor opens as shown.

(5) After doing the above steps, write a query in the editor, as shown.

Source Code:
–//LEN is used for calculating length of string Select LEN(‘ The Universe ‘) AS [LEN (Length of Name)] –//LEN is used for calculating length of string –//DATALENGTH is used for calculating length of string Select DATALENGTH(‘ The Universe ‘) AS [DATALENGTH (Length of Name)] –//DATALENGTH is used for calculating length of string |
(6) Then Execute or Press F5 to run the query and see the result as shown.
