

Ten Centuries
Group: General Forum Members
Last Login: Monday, March 23, 2015 12:01 PM
Points: 1,359,
Visits: 7,201


Comments posted to this topic are about the item Conversion
bc




SSC Veteran
Group: General Forum Members
Last Login: Wednesday, November 5, 2014 12:06 AM
Points: 217,
Visits: 172


My answer was correct but my reasoning for getting to the answer seemed to have been incorrect; I thought the error would be generated on printing integer and varchar variables together whereby a convert would be required for the int variable. But after reading the explanation to the answer and going through the msdn article, I learned something new. :)




SSCrazy
Group: General Forum Members
Last Login: Friday, March 27, 2015 6:14 AM
Points: 2,558,
Visits: 3,080


I thought putting the integer value 500000 into a varchar(5) would result in a string with value '50000' (removed last 0). Now I learned it's resulting in a string with value '*'.
Thanks for letting me learn someting new...
** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **




SSC Veteran
Group: General Forum Members
Last Login: Wednesday, November 5, 2014 12:06 AM
Points: 217,
Visits: 172


HanShi (10/6/2008)
I thought putting the integer value 500000 into a varchar(5) would result in a string with value '50000' (removed last 0). Now I learned it's resulting in a string with value '*'. Thanks for letting me learn someting new...
this was part of my thinking as well, that the value will just be truncated..... hence i moved on to the following steps and anticipated the error further down the statement list.




SSCrazy
Group: General Forum Members
Last Login: Today @ 12:54 PM
Points: 2,502,
Visits: 2,971


Thanks, neat question.
I'm sure this may not work every time, but I used the process of elimination based on the sums provided as answers.
I first assumed that there was no error, and that @first would be 50000 (truncated due to varchar(5)).
That led me to get @number + @first + @second = 500000 + 50000 + 50000 = 600000.
600000 wasn't one of the sums given as an answer, so I figured I should pick the error as my answer. Had 600000 been an available answer choice, I probably would have picked it and gotten the answer wrong.
Just my two cents if you want to make it tougher in the future to guess at the answers.
webrunner
 "Operator! Give me the number for 911!"  Homer Simpson
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sqljoke.html




Ten Centuries
Group: General Forum Members
Last Login: Tuesday, January 13, 2015 5:47 AM
Points: 1,274,
Visits: 1,988


I got thius right because I'd seen this error before, but also think more people would not have picked up the error if 600000 had been offered as an answer, i.e. 500000+'50000'+'50000'.
The other obvious wrong answer would be 500000, i.e. if you assume the truncation occurs to the right i.e. 500000 becomes '00000' (leading '5' dropped) and you then get 500000+'0'+'0'.
I'd be interested to see what logic is supposed to arrive at either 15000 or 150000 since I can't see any obvious way to get either of these.
Derek




SSCEnthusiastic
Group: General Forum Members
Last Login: Thursday, October 6, 2011 11:54 AM
Points: 154,
Visits: 203





Ten Centuries
Group: General Forum Members
Last Login: Monday, March 23, 2015 12:01 PM
Points: 1,359,
Visits: 7,201


i had a hard time coming up with false answers that would throw the reader off. i thought some might misread 50000 for 500000, and thus 150000 (50000+50000+50000). anyway this was my first attempt at writing a QOD. i hope a few people learned about this "gotcha" that puzzled me when i first came upon it in trying to answer another forum question. thanks
bc




SSCrazy
Group: General Forum Members
Last Login: Today @ 12:54 PM
Points: 2,502,
Visits: 2,971


bc (10/6/2008) i had a hard time coming up with false answers that would throw the reader off. i thought some might misread 50000 for 500000, and thus 150000 (50000+50000+50000). anyway this was my first attempt at writing a QOD. i hope a few people learned about this "gotcha" that puzzled me when i first came upon it in trying to answer another forum question. thanks
Well, you did catch a few people  about 9% :)  but if you had made one other choices 600000 (or 500000 as Derek suggests above), I'd say you would have caught closer to 25% combined with one of the wrong answers.
Still, you made a great question. You should try posting more of them!
webrunner
 "Operator! Give me the number for 911!"  Homer Simpson
"A SQL query walks into a bar and sees two tables. He walks up to them and says 'Can I join you?'" Ref.: http://tkyte.blogspot.com/2009/02/sqljoke.html




SSC Veteran
Group: General Forum Members
Last Login: Wednesday, November 5, 2014 12:06 AM
Points: 217,
Visits: 172


agreed this was an insightful question, well done!



