Sql-server – Reports with recurring events DB Schema in SQL Server

Architecturedatabase-designsql server

I'm trying to create a scheduling reporting feature where a user can schedule a report to be received "every 1st Monday of the month" or "every last day of the month" or "every week on Tuesday".

I saw an answer that talks about this somewhat, but I think it's more complicated than I need it. Calendar Recurring/Repeating Events – Best Storage Method.
My reports will always be starting immediately (not starting on a specific date) and it won't be rendering to a calendar. All I need to display is what options were chosen so it can be edited (what I mean to say is I don't need to display specific instances of a scheduled report but do need to display the rule.) The rules need to be stored in the DB and I'm at a loss on where to even begin. Any help would be greatly appreciated!

Best Answer

Take a look at the way SQL Server handles this for SQL Agent job schedules. Specifically, read through the columns prefixed freq_* as these determine the frequency of execution.

You could use the same or similar table schema to store frequency information about your reports. You could even display 'next scheduled date' information quite easily if you also stored the creation date of the schedule for a particular report.

There is a good article on SQLServerCentral that dives into this and should help you develop a solution that would suit.