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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 LEN() not able to detect the TRAILING spaces

Author  Topic 

vision.v1
Yak Posting Veteran

72 Posts

Posted - 2013-05-28 : 12:56:14
Hi,

I am using the LEN() function to get the number of characters in a string but its not able to detect correctly if contains TRAILING SPACES

Please see below example:

CREATE TABLE #temp
(
employeeName VARCHAR(50)
)

INSERT #temp VALUES('AAA ')
INSERT #temp VALUES('BBB')

SELECT LEN(employeeName) FROM #temp

For both the records its returning value as 3.

Please advise.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2013-05-28 : 13:59:24
use DataLength

LEN function excludes the trailing spaces

Cheers
MIK
Go to Top of Page

vision.v1
Yak Posting Veteran

72 Posts

Posted - 2013-05-29 : 04:48:00
Thanks, its worked for me

quote:
Originally posted by MIK_2008

use DataLength

LEN function excludes the trailing spaces

Cheers
MIK

Go to Top of Page
   

- Advertisement -