# left, right and %

• Comments posted to this topic are about the item left, right and %

• Hrm, why did I do left 4!

Ronald HensbergenHelp us, help yourself... Post data so we can read and use it: http://www.sqlservercentral.com/articles/Best+Practices/61537/-------------------------------------------------------------------------2+2=5 for significant large values of 2

• excellent question using left and right and the modulus sign .only problem remember to take the remainder for the answer not the amount left after a divide to a whole integer

• Nice question. One thing would have made it harder: having a fake string conversion error as an option. Honestly, I did not know that LEFT does an implicit conversion, but because there was no error as a choice, I figured it would convert correctly and then was able to work out the right - or should I say correct - answer.

So I'm happy that I got the correct answer, but I'm not happy that I didn't know about the implicit conversion. I suppose I should be happy, though, because that means that there is always more to learn with SQL Server! :w00t:

- webrunner

-------------------
A SQL query walks into a bar and sees two tables. He walks up to them and asks, "Can I join you?"
Ref.: http://tkyte.blogspot.com/2009/02/sql-joke.html

• webrunner (4/21/2009)

...One thing would have made it harder: having a fake string conversion error as an option...

I think that would have made the question worth the 2 points assigned to it. Not sure why a simple question like this is worth 2 points without it.

• Chris Harshman (4/21/2009)

webrunner (4/21/2009)

...One thing would have made it harder: having a fake string conversion error as an option...

I think that would have made the question worth the 2 points assigned to it. Not sure why a simple question like this is worth 2 points without it.

It was pay back for yesterday's question. Thanks Steve.

• Implicit conversion to/from strings? I would have expected an error. But, since that wasn't a choice, I calc'd it and came up with the answer. It's always nice to learn something new.

• I got the right and left part, I even figured it would convert as needed. What I couldn't do, was remember how Modulo worked. For some reason I thought to myself: 10 goes into 68 6 times, that must be correct. Then I got it wrong and immediately knew where I failed 🙁

• I put this as two as I thought it was slightly more interesting, and required more thought, than lots of the T-SQL ones we have.

• Steve Jones - Editor (4/21/2009)

I put this as two as I thought it was slightly more interesting, and required more thought, than lots of the T-SQL ones we have.

I'm not complaining, just saying I was suprised 😉

• No worries. I understand, and it made me rethink it a bit. It's debatable if this is worth two points, and I'm happy to have the opinions. I just eyeball them, so having people question it helps me to be sure I'm paying attention.

Memorization, and triva tend to be one point. Simple SQL as well.

Go to 2 pts when it seems to require more thought. Beyond that I'm guessing.

• Arrrg... it's a % and not a / ..... must drink more caffeine and get more sleep...

__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills

• I am surprised... how come right opertor on 568 with value 2 will return 68.In the end we will have 8 modulo 10 which will return 0.

Please correct me if I am wrong.

Viewing 13 posts - 1 through 13 (of 13 total)