June 14, 2010 at 8:44 pm
Good question, thanks!
Though I probably would have had the second option be 5, 2, 3...
June 14, 2010 at 11:38 pm
what's new in this question ?????
June 15, 2010 at 1:20 am
One easy point for me!
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
June 15, 2010 at 2:15 am
This one got me. I selected 5,5,5 because I'm used to having padding spaces with the CHAR datatype. That's why I use Varchar instead when the contents of the column doesn't contain a consistent number of characters.
if you were to select them without the LEN function, you would get
abcde ab... ab...
(the period was used to make spaces visible).
June 15, 2010 at 2:37 am
It's probably also worth pointing out that if you actually did want the physical length of the variables, you would use DATALENGTH() instead of LEN().
June 15, 2010 at 3:03 am
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!
_____________________________________________________________________
[font="Comic Sans MS"]"The difficult tasks we do immediately, the impossible takes a little longer"[/font]
June 15, 2010 at 5:14 am
Thanx a lot
everyday I learn from you new things...
June 15, 2010 at 7:37 am
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 🙂
June 15, 2010 at 7:46 am
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.
June 15, 2010 at 7:51 am
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
-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html
June 15, 2010 at 7:56 am
Easy basic programming RTRIM question.
SQL DBA.
June 15, 2010 at 8:13 am
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.
June 15, 2010 at 9:48 am
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.)
June 15, 2010 at 4:54 pm
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
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply