SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Conversion


Conversion

Author
Message
bc_
bc_
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1468 Visits: 7322
Comments posted to this topic are about the item Conversion

bc
Marius Els
Marius Els
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 180
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. Smile
HanShi
HanShi
SSCarpal Tunnel
SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)SSCarpal Tunnel (4.4K reputation)

Group: General Forum Members
Points: 4436 Visits: 3672
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...w00t

** Don't mistake the ‘stupidity of the crowd’ for the ‘wisdom of the group’! **
Marius Els
Marius Els
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 180
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...w00t


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.
webrunner
webrunner
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4199 Visits: 3887
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

-------------------
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
Ref.: http://www.adminarsenal.com/admin-arsenal-blog/powershell-how-to-write-your-first-powershell-script

"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
StarNamer
StarNamer
SSCommitted
SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)SSCommitted (1.7K reputation)

Group: General Forum Members
Points: 1662 Visits: 1992
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
Nikhil Shikarkhane
Nikhil Shikarkhane
SSC Veteran
SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)SSC Veteran (234 reputation)

Group: General Forum Members
Points: 234 Visits: 203
That was a good one...
bc_
bc_
UDP Broadcaster
UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)UDP Broadcaster (1.5K reputation)

Group: General Forum Members
Points: 1468 Visits: 7322
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
webrunner
webrunner
SSCarpal Tunnel
SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)SSCarpal Tunnel (4.2K reputation)

Group: General Forum Members
Points: 4199 Visits: 3887
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% Smile - 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

-------------------
"I love spending twice as long and working twice as hard to get half as much done!" – Nobody ever.
Ref.: http://www.adminarsenal.com/admin-arsenal-blog/powershell-how-to-write-your-first-powershell-script

"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
Marius Els
Marius Els
SSC Veteran
SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)SSC Veteran (260 reputation)

Group: General Forum Members
Points: 260 Visits: 180
agreed this was an insightful question, well done!
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search