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


The Percent Sign in T-SQL


The Percent Sign in T-SQL

Author
Message
SanDroid
SanDroid
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1576 Visits: 1046
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? :-P
mtillman-921105
mtillman-921105
SSC Eights!
SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)

Group: General Forum Members
Points: 822 Visits: 3852
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
BarbW
BarbW
Hall of Fame
Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)Hall of Fame (3.1K reputation)

Group: General Forum Members
Points: 3145 Visits: 1130
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 :-D
mtassin
mtassin
SSCarpal Tunnel
SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)SSCarpal Tunnel (4.8K reputation)

Group: General Forum Members
Points: 4796 Visits: 72518
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. Smile



--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
SanDroid
SanDroid
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1576 Visits: 1046
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.
SQLRNNR
SQLRNNR
SSC-Dedicated
SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)SSC-Dedicated (32K reputation)

Group: General Forum Members
Points: 32204 Visits: 18552
thanks for the question - straight forward.



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


SQL RNNR

Posting Performance Based Questions - Gail Shaw

UMG Developer
UMG Developer
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2678 Visits: 2204
Thanks for the nice easy start to the week!
Toreador
Toreador
SSCrazy
SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)SSCrazy (2.8K reputation)

Group: General Forum Members
Points: 2766 Visits: 8083
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 :-))
SQL-DBA-01
SQL-DBA-01
Hall of Fame
Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)Hall of Fame (3.7K reputation)

Group: General Forum Members
Points: 3661 Visits: 3283
Ambiguity in the question..!

Answer should be both..

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

Thanks.
mtillman-921105
mtillman-921105
SSC Eights!
SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)SSC Eights! (822 reputation)

Group: General Forum Members
Points: 822 Visits: 3852
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
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