Is there a MOD function for SqlServer's T-SQL?

Posted on 2005-04-06
Last Modified: 2008-01-09

     I know Oracle uses a MOD function like Basic's to determine the remainder after a division.  So 20 MOD 9 = 2 (9 goes into 20 twice for a total of 18, 20 - 18 = 2).  I need to determine a remainer in a T-SQL function I'm writing for Sql Server.  But there doesn't seem to be a MOD operator, or maybe it's a certain character or another name for it - I haven't found it yet though.  Does anyone know of one?

Question by:gleznov
    LVL 23

    Accepted Solution

    Yes, it's the % sign

    SELECT 20 % 9
    LVL 6

    Expert Comment

    set @a=10%3

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
    Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now