Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | 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
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vision.v1
Yak Posting Veteran

72 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
1054 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

72 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  
 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.05 seconds. Powered By: Snitz Forums 2000