Converting hex values

  • Comments posted to this topic are about the item Converting hex values

  • This was removed by the editor as SPAM

  • Yet another question where "None of the above" is the correct answer.

  • I like the ones where you have to try and figure out what's wrong with the question, then go for the option you think the questioner intended - thanks Steve! 😀

  • sipas (2/9/2016)


    I like the ones where you have to try and figure out what's wrong with the question, then go for the option you think the questioner intended - thanks Steve! 😀

    I do that with my code - litter it with unchecked errors. Much more fun than doing it right, I find.

  • That was a good one - it had me wondering what I did wrong for a little while.

  • FWIW:

    DECLARE @i VARBINARY = 0x0005432345544

    select LEFT(@i, 3), LEFT(CONVERT(VARCHAR(64),@i),3), LEFT(CONVERT(VARCHAR(64),@i,1),3), LEFT(CONVERT(VARCHAR(64),@i,2),3)

    produced:

    (No column name) (No column name) (No column name) (No column name)

    0x0 00

    on my box. So none of the answers are correct

  • Yeah, the VARBINARY with default length of 1 threw me off for a moment, since I expected some tricky "None of the above" answer. After seeing the answers, though, it was pretty clear what was intended.

    At any rate, the question prompted my getting reacquainted with all the caveats about converting to and from the binary types, so a nice start to the day!

  • gbritton1 (2/9/2016)


    FWIW:

    DECLARE @i VARBINARY = 0x0005432345544

    select LEFT(@i, 3), LEFT(CONVERT(VARCHAR(64),@i),3), LEFT(CONVERT(VARCHAR(64),@i,1),3), LEFT(CONVERT(VARCHAR(64),@i,2),3)

    produced:

    (No column name) (No column name) (No column name) (No column name)

    0x0 00

    on my box. So none of the answers are correct

    The same on my pc. However, interesting question.

    Igor Micev,My blog: www.igormicev.com

  • Ed Wagner (2/9/2016)


    That was a good one - it had me wondering what I did wrong for a little while.

    Me too, which is why I wrote the question

  • Steve Jones - SSC Editor (2/9/2016)


    Ed Wagner (2/9/2016)


    That was a good one - it had me wondering what I did wrong for a little while.

    Me too, which is why I wrote the question

    It looks like we weren't the only ones scratching our heads. I thought it was a good question, one of those that make you see what else is going on and check your assumptions.

  • I got to waste 15-20 minutes wondering why I wasn't getting the right results and experimenting before I realized there was a default.

  • None of the formula options produced the expected result. The correct answer to this QOD is None of the answers is correct.

  • julienchappel 38298 (2/9/2016)


    None of the formula options produced the expected result. The correct answer to this QOD is None of the answers is correct.

    That was part of the question. "None of the Above" wasn't an option. The real point of the question, beyond looking at the value, was the very common mistake present in the question.

  • Apologies, the hex value wasn't well formed.

    I've changed this to return 000 now

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic. Login to reply