September 11, 2013 at 3:46 am
How many results are returned from this batch?
DECLARE @i TABLE( mychar VARCHAR(10));
INSERT @i VALUES ('Steve'), ('Stephan'), ('Stephanie')
, ('Sterling'), ('Steppenwolf')
SELECT mychar
FROM @i
WHERE mychar LIKE 'Ste[^p]%'
Ans:-
Above Question it is giving error ,
if we change varchar(10) to varchar(12) then we can get 2 records as output.
September 11, 2013 at 3:49 am
Let Me Know if i am wrong:-)
September 11, 2013 at 3:49 am
Raghavendra Mudugal (9/11/2013)
Toreador
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. π
Dear, the answer is WRONG! are you following the posts here?
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
September 11, 2013 at 3:55 am
Despite the question having the wrong answer due to an error, I did learn something new about the ^.
A lot of the questions on here will never be used in practice but this could be. Thanks π
September 11, 2013 at 3:57 am
Hany Helmy (9/11/2013)
Raghavendra Mudugal (9/11/2013)
Toreador
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. π
Dear, the answer is WRONG! are you following the posts here?
Are you reading all my replies properly?
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:58 am
Hany Helmy (9/11/2013)
Raghavendra Mudugal (9/11/2013)
Toreador
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. π
Dear, the answer is WRONG! are you following the posts here?
As Tom pointed out above, the last five or so questions have had errors which have made the choice of answer something of a lottery. But it's a game, it's not important enough to get upset over.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 11, 2013 at 3:58 am
kapil_kk (9/10/2013)
Danny Ocean (9/10/2013)
handkot (9/10/2013)
I got an error: "String or binary data would be truncated. The statement has been terminated."(0 row(s) affected);-)
Just because of "Steppenwolf" having length 11. So insert statement is not executed successfully.
Correct answer should be "0".
:crazy:
I think, nobody check this question before post on SSC. This question is completely wrong.
Still i didn't believe that this question is posted by "Steve Jones - SSC Editor". :w00t:
+1
Totally agree:w00t:
+1
September 11, 2013 at 4:25 am
'Steppenwolf' is 11 characters so having declared the table as
DECLARE @i TABLE( mychar VARCHAR(10));
the insert will return an error.
The right answer should be 0!!
September 11, 2013 at 4:27 am
In SS2k you must use in T-SQL script this version:
INSERT @i VALUES ('Steve')
INSERT @i VALUES ('Stephan')
INSERT @i VALUES ('Stephanie')
INSERT @i VALUES ('Sterling')
INSERT @i VALUES ('Steppenwolf')
Then are 4 rows in the table @i inserted and correct answer is 2.
September 11, 2013 at 4:30 am
Ahh! Too many posts and none adding any value to the topic of discussion.
Wrong question or not, if it was able to teach you something new or refresh your memory about things you knew but had forgotten then it's worth it.
Go write your own QoTD and share knowledge with everyone.
September 11, 2013 at 4:41 am
Carlo Romagnano (9/11/2013)
The correct exceution of the query depends on ansi_warnings
set ansi_warnings off
DECLARE @i TABLE( mychar VARCHAR(10));
INSERT @i VALUES ('Steve'), ('Stephan'), ('Stephanie')
, ('Sterling'), ('Steppenwolf')
SELECT mychar
FROM @i
WHERE mychar LIKE 'Ste[^p]%'
It returns two rows in ONE resultset.
The question asks how many results ...?
The resultset is only ONE.
+1.
Anyway I understand people complaining as these things should be specified in the body of the question (like the other day with the garbage collector for FILESTREAM only in SQL2012 eg)
Thanks for the question though.
September 11, 2013 at 5:23 am
ksatpute123 (9/11/2013)
Ahh! Too many posts and none adding any value to the topic of discussion.Wrong question or not, if it was able to teach you something new or refresh your memory about things you knew but had forgotten then it's worth it.
Go write your own QoTD and share knowledge with everyone.
Some of us do that, and we screw things up from time to time; but something as blatantly wrong as today's question, or Monday's, is pretty rare.
The good thing to remember though, and this is why people shouldn't get too het up about today's question, is that an error as blatant as this will be fixed quite quickly: quite soon, probably by tomorrow, the question will have been changed to specify a greater length for the column so that the answer 2 really is correct; and probably everyone who has answered "incorrectly" up until that point will be given a point, so that no-one will have any grounds to feel they've been cheated of a point (as if that mattered).
Tom
September 11, 2013 at 5:24 am
DECLARE @i TABLE( mychar VARCHAR(10));
INSERT @i VALUES ('Steve'), ('Stephan'), ('Stephanie')
, ('Sterling'), ('Steppenwolf')
SELECT mychar
FROM @i
WHERE mychar LIKE 'Ste[^p]%'
Discordo do resultado ser "2", pelo fato de que no momento de gerar o insert ocorre um erro
"String or binary data would be truncated.", o ultimo nome 'Steppenwolf' excede 10 caracteres
I disagree with the result being "2", by the fact that at the time of the insert generate an error occurs
"String or binary data would be truncated.", The last name 'Steppenwolf' exceeds 10 characters
September 11, 2013 at 5:27 am
I actually saw the 11 characters in the last value and answered 0. When I got it wrong and read the explanation, I had to run it because I couldn't see what I missed. Turns out I didn't miss anything.
It looks like this was a simple mistake in what was marked as the correct answer. We all make mistakes.
September 11, 2013 at 5:31 am
Vobr Jiri (9/11/2013)
In SS2k you must use in T-SQL script this version:INSERT @i VALUES ('Steve')
INSERT @i VALUES ('Stephan')
INSERT @i VALUES ('Stephanie')
INSERT @i VALUES ('Sterling')
INSERT @i VALUES ('Steppenwolf')
Then are 4 rows in the table @i inserted and correct answer is 2.
SQL Server 2000 is no longer considered as a possible edition in the Questions.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
Viewing 15 posts - 46 through 60 (of 145 total)
You must be logged in to reply to this topic. Login to reply