December 2, 2014 at 10:16 pm
Comments posted to this topic are about the item What will be the output message?
December 3, 2014 at 12:23 am
Nice question.
The original INSERT statement misses one quote though.
But I figured out this was a typo and it had no influence on the answer. 😎
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
December 3, 2014 at 1:04 am
You're right, Koen.
December 3, 2014 at 2:14 am
Koen Verbeeck (12/3/2014)
Nice question.The original INSERT statement misses one quote though.
But I figured out this was a typo and it had no influence on the answer. 😎
Regardless to it being a typo or not the answer is still the same 🙂 only the error message is different
December 3, 2014 at 4:37 am
And if the first script is run together as a single batch, the table won't be created and the error message will be something else again!
December 3, 2014 at 4:56 am
This was removed by the editor as SPAM
December 3, 2014 at 5:18 am
Yeah, I saw the quote and found myself wondering if that was the trick. Then I saw what ended up being the answer and figured either way, the answer would be the same. Thanks.
December 3, 2014 at 6:21 am
I wonder if the missing quote was intentional, just to make us think harder, or an error.
The sarted out by thinking that we are told the table holds that data - so presumably we are to assume that although the insert statement we we are shown couldn't work (and there would be no table created, given how the code is presented) the table does exist and the data shown is what it holds (so the actual insert statement used to create it didn't have a missing quote). So I ignored all that and looked at the select. There is no filter in the select, and no distinct; therefor it either returns the same number of rows as in its source (4) or produces an error message. Is the select statement sound? No, it tries to use LEN on a text column - so it will produce an error.
But as others have pointed out, if we assume instead that the table creation and poulation use teh bathch shown in the question, so that the table doesn't exist, trying to select from it will produce an error anyway - so whether the missing quote is a real error or a red herring doesn't matter, what the final select produces is an error message either way.
Tom
December 3, 2014 at 6:33 am
Though the missing quote mark (which is most probably a typo); the question iteself is good, didn`t know that LEN fn doesn`t work with text data type (which I am not using anyway), good to know new things.
Many thanx.
Hany
Thanks & Best Regards,
Hany Helmy
SQL Server Database Consultant
December 3, 2014 at 7:04 am
Thanks for the great question.
December 3, 2014 at 7:06 am
Koen Verbeeck (12/3/2014)
Nice question.The original INSERT statement misses one quote though.
But I figured out this was a typo and it had no influence on the answer. 😎
+1
December 3, 2014 at 7:07 am
Good question, good explanation. Thanks!
December 3, 2014 at 7:11 am
Hany Helmy (12/3/2014)
Though the missing quote mark (which is most probably a typo
Not so much a typo, as forgetting to edit the text when it was copied and pasted from Wikipedia...
December 3, 2014 at 7:24 am
Is it really that hard to test the code out once before hitting submit?
December 3, 2014 at 7:47 am
Koen Verbeeck (12/3/2014)
Nice question.The original INSERT statement misses one quote though.
But I figured out this was a typo and it had no influence on the answer. 😎
That's what I did as well. After that, it was straight forward.
Jason...AKA CirqueDeSQLeil
_______________________________________________
I have given a name to my pain...MCM SQL Server, MVP
SQL RNNR
Posting Performance Based Questions - Gail Shaw[/url]
Learn Extended Events
Viewing 15 posts - 1 through 15 (of 20 total)
You must be logged in to reply to this topic. Login to reply