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 ««123»»

The Percent Sign in T-SQL Expand / Collapse
Author
Message
Posted Monday, February 28, 2011 9:08 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232, Visits: 1,046
mtassin (2/28/2011)
I got this right but...
SELECT 0%0
gives
Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.

So it seems you can use it to divide 0 by 0 and get an error.


Seriously?
Post #1070609
Posted Monday, February 28, 2011 9:17 AM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, July 14, 2014 10:08 AM
Points: 754, Visits: 3,816
sknox (2/28/2011)
mtassin (2/28/2011)
I got this right but...

SELECT 0%0

gives

Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.


So it seems you can use it to divide 0 by 0 and get an error.




This makes sense, since a modulus can be defined as a product of division, you have to be able to do the division. Some systems, though, define x mod 0 as x (i.e, the difference between x and the nearest multiple of 0 [which is 0 (because 0 is the only multiple of 0.)])


Yeah, I just included the "To divide by zero and get an error" as a joke. If you look at the symbol and take it at face value, that's what the symbol looks like.

p.s. To be more clear, it looks like a small zero divided by zero: 0/0.


______________________________________________________________________
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
Post #1070618
Posted Monday, February 28, 2011 9:29 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, August 29, 2014 7:58 AM
Points: 2,530, Visits: 1,030
I feel so silly for selecting the wrong answer - which was so obviously wrong..I am humbled. Thank goodness it's Monday so I can blame something
Post #1070622
Posted Monday, February 28, 2011 9:54 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Friday, August 22, 2014 7:04 AM
Points: 3,675, Visits: 72,433
mtillman-921105 (2/28/2011)
Yeah, I just included the "To divide by zero and get an error" as a joke. If you look at the symbol and take it at face value, that's what the symbol looks like.

p.s. To be more clear, it looks like a small zero divided by zero: 0/0.


Gotta be careful with jokes... as I said, I got this one right.

But somebody else could have said "Hey if I modulus 0 by 0 I get a divide by zero error!" and selected the last option, not realizing you were referring to what the % sign looks like. :)




--Mark Tassin
MCITP - SQL Server DBA
Proud member of the Anti-RBAR alliance.
For help with Performance click this link
For tips on how to post your problems
Post #1070636
Posted Monday, February 28, 2011 9:59 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, January 31, 2013 8:01 AM
Points: 1,232, Visits: 1,046
mtassin (2/28/2011)
[quote]
But somebody else could have said "Hey if I modulus 0 by 0 I get a divide by zero error!" and selected the last option, not realizing you were referring to what the % sign looks like.


Which would mean nothing unless they could find documentation supporting the obvious wrong answer. It was a multiple choice question with one right answer.
Test taking 101 tells us to select the answer that is MOST correct.
That was answer 3.

I like it when there are joke answers that are funny IF you understand the questions, or what you are reading. It has been proven that these questions improve learning.
Post #1070640
Posted Monday, February 28, 2011 12:52 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Friday, August 29, 2014 1:51 PM
Points: 21,644, Visits: 15,317
thanks for the question - straight forward.



Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Posting Data Etiquette - Jeff Moden
Hidden RBAR - Jeff Moden
VLFs and the Tran Log - Kimberly Tripp
Post #1070771
Posted Monday, February 28, 2011 1:15 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Monday, June 16, 2014 9:38 AM
Points: 2,163, Visits: 2,189
Thanks for the nice easy start to the week!
Post #1070787
Posted Tuesday, March 1, 2011 2:25 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:20 AM
Points: 1,740, Visits: 6,366
SanDroid (2/28/2011)
So happy that over 80 percent of us know math.

Can you imagine how hard it would be a SQL developer or DBA if you didn't learn higher level math?


What's maths got to do with it? The use of % for modulo is a computing term. The mathemetical equivalent would be 'mod', though it's meaning is similar rather than identical.

eg 8 % 6 = 2
means roughly the same as
8 = 2 (mod 6)
or more accurately
8 ≡ 2 (mod 6)

(note it's 25 years since I graduated so I'm probably about to be humilated when someone points out that I'm talking nonsense )
Post #1071046
Posted Tuesday, March 1, 2011 2:17 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, August 29, 2014 10:11 AM
Points: 831, Visits: 1,376
Ambiguity in the question..!

Answer should be both..

(1) divide by zero/ (2) remainder.


Thanks.
Post #1071589
Posted Tuesday, March 1, 2011 2:24 PM


Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Monday, July 14, 2014 10:08 AM
Points: 754, Visits: 3,816
OK, the next time I submit a question, I'll be sure that the fluke answer, if there is one included, can in no way be misconstrued as a possible right answer.

I think some of you are used to trick questions, so you're looking for a sneaky answer.


______________________________________________________________________
The greatest enemy of knowledge is not ignorance, it is the illusion of knowledge. - Stephen Hawking
Post #1071595
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse