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:46 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 8:41 AM
Points: 2,818, Visits: 2,553
rjv_rnjn (6/15/2010)
crussell-931424 (6/15/2010)
Yep, it only does an RTRIM, not an LTRIM.
This variation to the question may have been a better teaser


Good point. In a month or so, this RTRIM/LTRIM variation would be a good question, after everyone has forgotten this question, and its discussion.
Post #937505
Posted Tuesday, June 15, 2010 7:51 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 11:50 AM
Points: 2,328, Visits: 2,658
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
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Monday, July 7, 2014 8:58 AM
Points: 642, Visits: 400
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


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, May 28, 2014 1:04 PM
Points: 1,313, Visits: 1,055
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: Friday, July 11, 2014 12:42 PM
Points: 1,380, Visits: 2,682
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


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 7:44 PM
Points: 21,209, Visits: 14,899
Thanks for the QOD



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #938634
Posted Tuesday, June 22, 2010 3:59 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 3:53 PM
Points: 262, Visits: 300
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