I have a column of values and I need it to update every 24 hours decreasing the maximum value by 1 until it reaches 0, and after that SQL will delete it. How could I do this on SQL Server?
Asked
Active
Viewed 197 times
-2
-
1What has your research show you? This is a frequently asked question. – Dale K Sep 18 '20 at 02:40
-
maybe I haven't seen it, but I looked – Opan Sep 18 '20 at 02:43
-
1The engine itself does not do this. You will need to _schedule_ (hint) something. – SMor Sep 18 '20 at 02:45
-
https://stackoverflow.com/questions/40958990/update-record-inserted-in-table-after-one-hour – Dale K Sep 18 '20 at 02:46
-
unsuccessful with Sql Server 2008 R2 – Opan Sep 18 '20 at 03:07
-
That was just the first result of my google search... there were loads... – Dale K Sep 18 '20 at 03:11
1 Answers
1
You can write a stored procedure that runs the code and schedule it using SQL Agent.

Dale K
- 25,246
- 15
- 42
- 71

luisvenezian
- 441
- 5
- 18