Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Conversion Expand / Collapse
Author
Message
Posted Saturday, October 4, 2008 1:32 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 4:39 PM
Points: 1,343, Visits: 7,185
Comments posted to this topic are about the item Conversion

bc
Post #580747
Posted Monday, October 6, 2008 4:24 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 22, 2014 12:09 PM
Points: 217, Visits: 171
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. :)
Post #580993
Posted Monday, October 6, 2008 5:59 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, October 27, 2014 8:18 AM
Points: 2,404, Visits: 2,940
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’! **
Post #581025
Posted Monday, October 6, 2008 6:20 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 22, 2014 12:09 PM
Points: 217, Visits: 171
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.
Post #581031
Posted Monday, October 6, 2008 7:15 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:04 PM
Points: 2,394, Visits: 2,788
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/sql-joke.html
Post #581073
Posted Monday, October 6, 2008 8:05 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, October 20, 2014 5:17 AM
Points: 1,274, Visits: 1,985
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
Post #581094
Posted Monday, October 6, 2008 2:30 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Thursday, October 6, 2011 11:54 AM
Points: 154, Visits: 203
That was a good one...
Post #581376
Posted Monday, October 6, 2008 2:40 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 4:39 PM
Points: 1,343, Visits: 7,185
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
Post #581382
Posted Monday, October 6, 2008 2:44 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Yesterday @ 12:04 PM
Points: 2,394, Visits: 2,788
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/sql-joke.html
Post #581383
Posted Monday, October 6, 2008 10:26 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, September 22, 2014 12:09 PM
Points: 217, Visits: 171
agreed this was an insightful question, well done!
Post #581501
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse