SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 LEN() not able to detect the TRAILING spaces
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vision.v1
Yak Posting Veteran

71 Posts

Posted - 05/28/2013 :  12:56:14  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Pakistan
1052 Posts

Posted - 05/28/2013 :  13:59:24  Show Profile  Reply with Quote
use DataLength

LEN function excludes the trailing spaces

Cheers
MIK
Go to Top of Page

vision.v1
Yak Posting Veteran

71 Posts

Posted - 05/29/2013 :  04:48:00  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000