Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
What is the difference between len() and DATALENGTH. I tried both in a SELECT, both are returning the same value. Can someone give me an example?------------------------I think, therefore I am - Rene Descartes
madhivanan
Premature Yak Congratulator
22864 Posts
Posted - 2005-09-21 : 05:55:29
Len will trim the data but DATALENGTH doesnt do itSelect Len('Test ')Select DATALENGTH ('Test ')MadhivananFailing to plan is Planning to fail
Arnold Fribble
Yak-finder General
1961 Posts
Posted - 2005-09-21 : 05:58:28
DATALENGTH returns the length of the string in bytes, including trailing spaces. LEN returns the length in characters, excluding trailing spaces. For example,