I have a program that uses a licence system for its users. Now I have an integer column LicenceDays in my database, and I would like to decrement that value every 24 hours by 1. So lets say for example my LicenceDays is at 4, after 24 hours make an update to the database and it will be at 3.
Now I don’t get how I would go about that. Where do I start? Can I achieve this in Sql Server itself, or could I use some sort of code in my WPF C# Program? I’m using LINQ to SQL to access my database.
Any help would be appreciated, Thanks.
Since this is a recurring SQL task, probably the easiest and most maintainable solution would be to create a job within SQL Server itself. You can write your SQL statement that decreases “LicenseDays” by 1, and schedule it to run every 24 hours. You can even schedule, update and start/stop this using the GUI within SQL Server Management Studio.
More info on SQL Server jobs: http://msdn.microsoft.com/en-us/library/ms190268.aspx