Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

difference between datalength() and len()

Posted on 2008-10-03
4
Medium Priority
?
1,570 Views
Last Modified: 2012-05-05
can i know what is difference between datalength() and len() functions in ms sql.
0
Comment
Question by:pavanark
4 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 672 total points
ID: 22632219
datalength returns number of bytes used by any expression
len returns number of characters in string expression
which means that for strings, if the string is unicode you might get a different result since each character can be represented using 2 bytes
for numeric expressions you can only use datalength
0
 
LVL 17

Assisted Solution

by:HuyBD
HuyBD earned 672 total points
ID: 22632220
datalength() returns the length of the string in bytes without trimming.
len() returns the length in characters with trimming
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 672 total points
ID: 22632452
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question