Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

LEN() Expand / Collapse
Author
Message
Posted Tuesday, June 15, 2010 7:51 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 2:31 PM
Points: 2,428, Visits: 2,861
F1Droid (6/15/2010)
Aargh!! Again my initial reaction was "that's easy it's 5,2,2 as LEN ignores spaces"... and then "hmmm, but that's too easy, there must be a trick in there"... and after a bit of reading went against my initial conclusion...

Doh!!

Good lesson though... trust yourself!


Yes, the same thing happened to me.

- webrunner


-------------------
"Operator! Give me the number for 911!" - Homer Simpson

"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
Post #937512
Posted Tuesday, June 15, 2010 7:56 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
Easy basic programming RTRIM question.

SQL DBA.
Post #937516
Posted Tuesday, June 15, 2010 8:13 AM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Tuesday, December 9, 2014 8:18 PM
Points: 665, Visits: 405
UMG Developer (6/14/2010)
...I probably would have had the second option be 5, 2, 3...

Agreed. I think 5,2,5 makes no sense and should influence a decision in favor of 5,2,2.
Post #937539
Posted Tuesday, June 15, 2010 9:48 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Friday, September 19, 2014 7:15 AM
Points: 1,447, Visits: 1,059
As usual, I learn more from the discussion than the original question.

If this had been the question:

SET @aa = 'abcde';SET @bb = ' ab';SET @cc = 'ab '

I would have gotten it wrong.




(I meant no disrespect to the author of the question. My point was that a thread of "what if this" and "what if that" is always educational.)
Post #937643
Posted Tuesday, June 15, 2010 4:54 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Tuesday, December 2, 2014 11:00 AM
Points: 1,142, Visits: 2,693
wware (6/15/2010)
As usual, I learn more from the discussion than the original question.

If this had been the question:

SET @aa = 'abcde';SET @bb = ' ab';SET @cc = 'ab '

I would have gotten it wrong.


I was a bit nervous before I answered the question that there was more to the question like what your example was.


---------------------------------------------------------------------
Use Full Links:
KB Article from Microsoft on how to ask a question on a Forum
Post #937878
Posted Wednesday, June 16, 2010 9:30 PM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 6:41 AM
Points: 18,055, Visits: 16,088
Thanks for the QOD



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #938634
Posted Tuesday, June 22, 2010 3:59 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 10:23 PM
Points: 306, Visits: 341
Made me question the way char's are handled in len() as we always use varchar, so thanks!
Post #941393
Posted Monday, October 4, 2010 7:33 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Sunday, November 17, 2013 11:53 AM
Points: 623, Visits: 237
i thought ans would be 5 2 3 but as it wasn't present i have to search and found that space is ignored
would have been better if we have option of 5 2 3. many of us would have got that wrong
Post #997546
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse