September 11, 2013 at 2:13 am
Toreador (9/11/2013)
Koen Verbeeck (9/11/2013)
Indeed. As if I'm going to count the number of characters in Steppenwolf.Why wouldn't you? I did, and got it wrong as a result.
I was guessing though, as I didn't know whether the invalid value would prevent all the others being inserted or not.
Exactly what I was saying! what`s the problem of counting the characters of a value?! and what`s the problem of being Accurate to get the correct answer?!
And by the way, why Steve didn`t reply to all these posts until now?! maybe he's busy with something!
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 11, 2013 at 2:20 am
Nice question.
Results are very obvious.
It needs
DECLARE @i TABLE( mychar VARCHAR(11));
Igor Micev,My blog: www.igormicev.com
September 11, 2013 at 2:26 am
Koen Verbeeck (9/11/2013)
Indeed. As if I'm going to count the number of characters in Steppenwolf.
Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, I thought "Aha! Sneaky trick question time!" and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. Maybe it's a bit of a Pavlov reaction to be looking for tricks where there were apparently intended to be none, due to getting burned by that on so many QotDs in the past; still, doesn't stop this being a poor question because it demonstrably does not return the answer specified.
(Heck, if the question is just asking about pattern matching, it didn't even need to use a script--Steve could have listed the strings and asked, "How many of these does the pattern 'Ste[^p]%' match?").
September 11, 2013 at 2:27 am
If you oversight the 11 Character (Binary Data truncated issue), otherwise good question to learn something new.
September 11, 2013 at 2:42 am
paul.knibbs (9/11/2013)
Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. doesn't stop this being a poor question because it demonstrably does not return the answer specified.
Same steps I did,
Totally agree it`s a poor question (not nice @ all like some here said) as the answer is wrong & not explained well.
The only thing could made this question nice & correct if it was mentioned in the beginning:
Set Ansi_Warnings off;
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 11, 2013 at 3:06 am
Come on guys, it's pretty obvious what the point of the question was and knocking the last letter off of 'Steppenwolf' makes everything work as the OP intended.
If you're worried because you "lost a point" because the code failed when you ran it bear in mind that the point of QOTD is to make you think a bit. Anybody can actually run the code to get the (normally) right answer - it means nothing. As all you need to do to get a point is write a post containing "+1" every day (which at least one person does) they're not exactly hard to come by.
I didn't run the code so actually got it right as I assumed the length thing wasn't a deliberate trap.:-)
September 11, 2013 at 3:07 am
Good question, Steve. Thank you for posting.
(Apart from the issue in the string length which can be known when one executes the statement, I just analyzed the question without executing and picked the right answer. Executing the SQL from the qtod is not a proper way for picking the answer, but some complex qtods needs executing, and definitely this one is not, so come on guys..... you all are Pros here. I know most of them here (or all) do not consider my reply as acceptable...but I don't mind, and even this applies to me. π )
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 11, 2013 at 3:09 am
Raghavendra Mudugal (9/11/2013)
I just analyzed the question without executing and picked the right answer.
You clearly didn't analyse it very well then π
September 11, 2013 at 3:18 am
Toreador (9/11/2013)
Raghavendra Mudugal (9/11/2013)
I just analyzed the question without executing and picked the right answer.You clearly didn't analyse it very well then π
Good one π
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 11, 2013 at 3:21 am
Three out of the last five questions wrong. This is a pretty terrible patch, isn't it. And last Thursday's still not corrected, so it continues to encourage a growing myth.
Tom
September 11, 2013 at 3:31 am
paul.knibbs (9/11/2013)
Koen Verbeeck (9/11/2013)
Indeed. As if I'm going to count the number of characters in Steppenwolf.
Why not? I did, because I immediately thought the word looked too long for a 10-character field, and when I totalled it up to 11, I thought "Aha! Sneaky trick question time!" and put 0 in. Was very surprised when the question claimed the answer to be 2, so I went and ran the script and got exactly the same result; no rows inserted due to the error, so no results returned. Maybe it's a bit of a Pavlov reaction to be looking for tricks where there were apparently intended to be none, due to getting burned by that on so many QotDs in the past; still, doesn't stop this being a poor question because it demonstrably does not return the answer specified.
(Heck, if the question is just asking about pattern matching, it didn't even need to use a script--Steve could have listed the strings and asked, "How many of these does the pattern 'Ste[^p]%' match?").
First thing I did was check the pattern and get 2; but in doing that I noticed Steppenwolf looked quite long. So I counted the characters, and got 11. I reckoned that 11 was greater than 10, and therefor answered 0. I didn't bother to run the code when that turned out not to be the "correct" answer, what would be the point in doing that? I didn't think that that part of the T-SQL language definition would have suddenly changed while I wasn't looking π and it seemed even less likely that 10 had suddenly become greater than or equal to 11 :w00t:. So it was quite clear that the "correct" answer was wrong, yet again.
Tom
September 11, 2013 at 3:36 am
Got the error message:
Msg 8152, Level 16, State 14, Line 3
String or binary data would be truncated.
The statement has been terminated.
(0 row(s) affected)
π
September 11, 2013 at 3:36 am
L' Eomot InversΓ© (9/11/2013)I didn't bother to run the code when that turned out not to be the "correct" answer, what would be the point in doing that?
I did that because sometimes the QotD is demonstrating a quirk or even bug in SQL server that gives unexpected results--true, the answer didn't say anything along those lines, but I thought I'd best run the script anyway to make sure I wasn't going completely insane. π
September 11, 2013 at 3:40 am
Toreador (9/11/2013)
Raghavendra Mudugal (9/11/2013)
I just analyzed the question without executing and picked the right answer.You clearly didn't analyse it very well then π
If I didn't then I would never had got the answer correct.. but I did, and this is all it needs for this qtod. π
ww; Raghu
--
The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.
September 11, 2013 at 3:40 am
To Err is human .... π
if one ignore the "String or binary data would be truncated." error .. which i do
so good question ...
Just a tiny little advice to author, do the final check on code before posting ... π
Viewing 15 posts - 31 through 45 (of 145 total)
You must be logged in to reply to this topic. Login to reply