Solved

difference between datalength() and len()

Posted on 2008-10-03
4
1,566 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 37

Accepted Solution

by:
momi_sabag earned 168 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 168 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 168 total points
ID: 22632452
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how the fundamental information of how to create a table.

752 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