SQL Express Decrement Column Value

Posted on 2008-11-06
Last Modified: 2012-06-27
    I have an SQL Express 2005 table 'Dispensations' with a 'DaysLeftToCompletion' integer column & a  'Status' nchar(10) column (amongst other columns). At midnight each day I wish to run a SQL script that will decrement the value in the 'DaysLeftToCompletion' column by 1 only if the 'Status' column has a value of 'Active'. If the 'DaysLeftToCompletion' value is zero then it should remain at zero.

Any help appreciated.
Question by:pr_wainwright
    1 Comment
    LVL 16

    Accepted Solution

    Update TableName
    Set DaysLeftToCompletion = DaysLeftToCompletion - 1
    Where DaysLeftToCompletion > 0
    AND Status = 'Active'


    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
    In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This video discusses moving either the default database or any database to a new volume.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 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

    19 Experts available now in Live!

    Get 1:1 Help Now