I have a C# program that will run nightly. It reads in records from flat files and does many different inserts and updates to a SQL Server database depending on the contents of each record.
Despite using transaction blocks and Try...Catch
in stored procedures, and Try...Catch
in C#, I really need these updates to be all or nothing.
I cannot take snapshots of db since we are using SQL Server 2008 R2 Express edition.
Can anyone please explain a good method (if there is one) for returning the SQL Server database to the state it was in before the nightly C# job ran, if the C# program catches an error? Basically, if the C# program catches an error, I want it to stop running, and I want to "rollback" the database to before the C# program did any changes. I need this to be an automated solution, not a manual restore from a backup.
In a sense, I want a Transaction block around the C# program that could rollback everything the C# program did.
The database is in Multi_User
mode with a full recovery model (with nightly scheduled db and log backups). There is a web app tied to this database, but end users should really never have need to access this web app in the middle of the night.
I have searched everywhere for solutions, but no luck. Perhaps not using right keywords.
I look forward to feedback.
Thanks in advance, David