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: Wednesday, May 22, 2013 1:10 PM
Points: 2,673, Visits: 2,418
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: Yesterday @ 1:47 PM
Points: 2,118, Visits: 2,213
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


-------------------
"The chemistry must be respected." - Walter White

"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: Friday, March 15, 2013 2:43 PM
Points: 3,924, Visits: 1,554
Easy basic programming RTRIM question.

SQL DBA.
Post #937516
Posted Tuesday, June 15, 2010 8:13 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Thursday, January 17, 2013 2:34 PM
Points: 565, Visits: 360
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: Thursday, May 16, 2013 9:42 AM
Points: 1,072, Visits: 1,026
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: Wednesday, May 01, 2013 4:52 PM
Points: 1,379, Visits: 2,626
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: Yesterday @ 10:25 AM
Points: 18,754, Visits: 12,337
Thanks for the QOD



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


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: Tuesday, April 30, 2013 7:26 PM
Points: 254, Visits: 277
Made me question the way char's are handled in len() as we always use varchar, so thanks!
Post #941393
Posted Monday, October 04, 2010 7:33 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Wednesday, July 25, 2012 9:04 PM
Points: 542, Visits: 187
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