May 8, 2012 at 8:21 pm
Comments posted to this topic are about the item String comparison
May 8, 2012 at 8:37 pm
Nice question ..... and it teaches something additional ... it teaches one to read definitions as well as the T-SQL very, very closely
May 8, 2012 at 11:15 pm
Great question.
Although, the first X returned is not just X but X with 19 spaces. SSMS doesn't really show it that well, but if you copy paste the value you'll see the spaces.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
May 8, 2012 at 11:40 pm
Very good question! The question proves that the devil is in the details! The question teaches everyone a lot of things.
Thank-you!
Thanks & Regards,
Nakul Vachhrajani.
http://nakulvachhrajani.com
Follow me on
Twitter: @sqltwins
May 9, 2012 at 12:44 am
A very good question, even if i missed it. ๐
I thought, if the LEN delivers 1, then the LIKE makes the same. For me a bit inconsistent, but good to know how stuff works.
May 9, 2012 at 12:50 am
Nice question, thank you
Iulian
May 9, 2012 at 1:14 am
Excellent question. I often come across code such as
IF col1 like col2 (without any wildcards)
and I've often wondered why they didn't just put IF col1=col2. Til today I assumed they were equivalent. (I wonder if those that wrote this code appreciate the nuance.)
Thanks for expanding my knowledge.
May 9, 2012 at 2:04 am
Nice question!
However, the explanation and reference are slightly incomplete, as they don't explain the behaviour of @a LIKE @b-2 versus @ LIKE @a.
The explanation for that can simply be found in the Books Online article on LIKE, in the "Remarks" section. Link: http://msdn.microsoft.com/en-us/library/ms179859.aspx
May 9, 2012 at 4:44 am
Nice question.
-----------------
Gobikannan
May 9, 2012 at 5:09 am
Good question.
It would have been somewhat shocking if I had got this one wrong after writing the 15th April 2010 QotD ๐
Tom
May 9, 2012 at 5:13 am
Hugo Kornelis (5/9/2012)
Nice question!However, the explanation and reference are slightly incomplete, as they don't explain the behaviour of @a LIKE @b-2 versus @ LIKE @a.
The explanation for that can simply be found in the Books Online article on LIKE, in the "Remarks" section. Link: http://msdn.microsoft.com/en-us/library/ms179859.aspx
Actually I think he did explain it - I guess it depends on how you interpret "on the right". I interpret it as meaning "on the right hand side of "LIKE", I guess you must interpret it as "on the right hand side of a string" which is a bit bizarre because if that's what he'd have got it wrong and had two "false" values instead of getting it right and having one. The wording could have been better, but it seems perverse to interpret as implying a different answer from teh one he gave.
Tom
May 9, 2012 at 5:19 am
L' Eomot Inversรฉ (5/9/2012)
Hugo Kornelis (5/9/2012)
Nice question!However, the explanation and reference are slightly incomplete, as they don't explain the behaviour of @a LIKE @b-2 versus @ LIKE @a.
The explanation for that can simply be found in the Books Online article on LIKE, in the "Remarks" section. Link: http://msdn.microsoft.com/en-us/library/ms179859.aspx
Actually I think he did explain it - I guess it depends on how you interpret "on the right". I interpret it as meaning "on the right hand side of "LIKE", I guess you must interpret it as "on the right hand side of a string" which is a bit bizarre because if that's what he'd have got it wrong and had two "false" values instead of getting it right and having one. The wording could have been better, but it seems perverse to interpret as implying a different answer from teh one he gave.
You are right, Tom. On the right can only be meant to apply to he LIKE and not to the string, as that is already implied by the word "trailing". I didn't read the explanation carrefully enough.
May 9, 2012 at 5:21 am
Nice question!!!!
thanks!!!!
May 9, 2012 at 6:11 am
Nice question - almost missed it. Re-Review of code caused me to change my answer at the last minute. ๐
Steve Jimmo
Sr DBA
โIf we ever forget that we are One Nation Under God, then we will be a Nation gone under." - Ronald Reagan
Viewing 15 posts - 1 through 15 (of 27 total)
You must be logged in to reply to this topic. Login to reply