Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

DATALENGTH Function in SQL Server: A Practical Guide

Understand DATALENGTH Function in SQL Server with clear explanations, practical examples, and useful tips. This updated guide covers the essential concepts...

Table of Contents

DATALENGTH Function in SQL Server is easier to understand when the core ideas are paired with practical examples. The sections below explain the topic clearly, highlight useful steps, and point out details that can prevent common errors.

The article will explore and show you how to use the DATALENGTH function in SQL Server to display the number of bytes used to represent an expression.

Describe

The DATALENGTH function in SQL Server returns the length of an expression, in bytes.

Syntax

To use the DATALENGTH function in SQL Server, we use the following syntax:

 DATALENGTH(bieu_thuc) 
 SELECT DATALENGTH('TipsMake.com'); 
 Result: 15 
 
 SELECT DATALENGTH(' TipsMake.com '); 
 Result: 17 
 
 SELECT DATALENGTH(1234); 
 Result: 4 
 
 SELECT DATALENGTH('20-02-2019'); 
 Result: 10 
 
 SELECT DATALENGTH(' '); 
 Result: 1 
 
 SELECT DATALENGTH(''); 
 Result: 0 
 
 SELECT DATALENGTH(NULL); 
 Result: NULL 

Next lesson: LEFT function in SQL Server

FAQ

What should you know about describe?

The DATALENGTH function in SQL Server returns the length of an expression, in bytes.

What should you know about syntax?

To use the DATALENGTH function in SQL Server, we use the following syntax:

What is DATALENGTH Function in SQL Server?

The article will explore and show you how to use the DATALENGTH function in SQL Server to display the number of bytes used to represent an expression.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.