DATALENGTH() Function in SQL Server Last Updated : 03 Dec, 2020 Comments Improve Suggest changes Like Article Like Report DATALENGTH() : This function returns the length of an expression and expression length will be in bytes. Syntax : DATALENGTH( expression ) Parameter - This method accepts a single-parameter as mentioned above and described below as follows. Expression - It is an expression of the data type to return the length for. If expression is NULL, it returns NULL. Returns : It returns the number of bytes used to represent an expression. Example-1 : Return the length of an expression. SELECT DATALENGTH('Geeksforgeeks'); Output : 13 Example-2 : Check DATALENGTH() Function count trailing spaces or not. SELECT DATALENGTH('GFG '); Output : 6 Example-3 : Check DATALENGTH() Function count leading spaces or not. SELECT DATALENGTH(' GFG'); Output : 7 Example-4 : DATALENGTH() Function return NULL, if the expression is NULL. SELECT DATALENGTH(NULL); Output : NULL Comment More infoAdvertise with us Next Article DATALENGTH() Function in SQL Server S sanjoy_62 Follow Improve Article Tags : SQL DBMS-SQL SQL-Server Similar Reads DATENAME() Function in SQL Server DATENAME() function : This function in SQL Server is used to find a given part of the specified date. Moreover, it returns the output value as a string. Features : This function is used to find a given part of the specified date.This function comes under Date Functions.This function accepts two para 2 min read DATEPART() Function in SQL Server DATEPART() function :This function in SQL Server is used to find a given part of the specified date. Moreover, it returns the output value as an integer.Features : This function is used to find a given part of the specified date.This function comes under Date Functions.This function accepts two para 2 min read AVG() Function in SQL Server The AVG() function in SQL Server is an essential aggregate function used to compute the average value of a numeric column. It works by summing all non-NULL values in the specified column and then dividing the total by the number of these values. In this article, We will learn about AVG() Function in 3 min read COUNT() Function in SQL Server The COUNT() function in SQL Server is a fundamental aggregate function used to determine the number of rows that match a specific condition. Counting rows provides valuable insights into data sets such as the total number of records, distinct values, or records meeting certain criteria.In this artic 3 min read SQL Server DATEDIFF() Function The DATEDIFF() function in SQL Server is a powerful tool used to calculate the difference between two dates or times. It returns an integer representing the number of date or time boundaries crossed between the specified dates, based on the specified date. This function is essential for tasks that i 3 min read Like