Use of DATALENGTH Function in SQL:
(1) “DATALENGTH” function is used to calculate the length of the string.
(2) Let’s take an example to calculate the length of the “Name” field in Vendor Table 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:
–//DATALENgth is used for caculating length of string Select [No_] as [Vendor No.],[Name] as [Vendor Name], DATALENGTH([Name])AS [Length of Name] fromdbo.[CRONUS India Ltd_$Vendor$437dbf0e-84ff-417a-965d-ed2bb9650972] TB1 –//DATALENgth is used for caculating length of string |
(6) Then Execute or Press F5 to run the query and see the result as shown.
