Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Modulus operator in SQL Server

Jan 20 2011 6:23AM by Madhivanan   

Modulus operator is used to find the remainder after the division. All programming languages have specific operators to find a remainder like mod, rem, etc. In SQL Server, we can use modulus operator %. However we can also use general approach to find a remainder.

Here are two methods

Method 1 : Use modulus operator (%)

declare @n1 int, @n2 int
select @n1=16,@n2=7
select @n1%@n2 

Method 2 : Use general approach

declare @n1 int, @n2 int
select @n1=16,@n2=7
select  @n1-@n2*(@n1/@n2)

In both the methods the result is 2

Tags: t-sql, sql_server, sqlserver, tsql, BRH, #TSQL, function, #SQLServer, modulus,


Madhivanan
3 · 40% · 12947
2
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

2  Comments  

  • Often overlooked useful application of the modulus operator is extracting a fractional part of the decimal number. For a number Num it will be Num%1.

    commented on Dec 10 2012 2:53PM
    Leonid Koyfman
    50 · 4% · 1183
  • Thanks Leonid Koyfman. Yes thats simpler way of finding a fractional part

    commented on Dec 13 2012 12:15AM
    Madhivanan
    3 · 40% · 12947

Your Comment


Sign Up or Login to post a comment.

"Modulus operator in SQL Server" rated 5 out of 5 by 2 readers
Modulus operator in SQL Server , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]