Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Syntax: <field> % 2 = 1

Author  Topic 

mikeynero
Starting Member

2 Posts

Posted - 2010-08-06 : 14:15:25
Hello,
I recently saw this syntax in a book and am not keen on it. Can anyone explain? This constraint for sure filters our records, I am not keen on the % syntax here. Thanks

where OrderID % 2 = 1

Michael Nero

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-08-06 : 14:24:34
% is the modulo operator. So that bit of code is checking if the remainder is 1 if you divide OrderID by 2.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-08-07 : 04:50:27
In other words, it'll return all records where OrderID is odd.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

mikeynero
Starting Member

2 Posts

Posted - 2010-08-07 : 13:11:58
Thank you all for the input

Michael Nero
Go to Top of Page
   

- Advertisement -