Monitor data and update it conditionally

  • Hi,

    Is there a way for monitoring data in a table and update it when it exists in the table longer than a period of time?

    For example, a table has a column called "measure", if the column contained value > 0 longer than 15 minutes then update it to be 0.

    Any help would be appreciated.




  • Write a batch that periodically checks new items based on a timestamp? Do the records have a modified timestamp? (better to check on one column)

  • Yeah, total agreement with Jo. It's just a question of probing the table on a regular basis to see what the status is. There is no such thing as a time trigger within SQL Server. Instead, you use an external scheduler like SQL Agent or something else. Run a query every fifteen minutes. In that query, don't even do a check and then an update. Just do an update where the criteria matches. Single batch statement and done.

    The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood...
    Theodore Roosevelt

    The Scary DBA
    Author of: SQL Server 2017 Query Performance Tuning, 5th Edition and SQL Server Execution Plans, 3rd Edition
    Product Evangelist for Red Gate Software

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply