Franz
Franz

Reputation: 2049

Rollback SQL Server from code

Guess my problem is pretty much popular, like INFORMIX DB ROLLBACK we are developing long running algorithms on our database using DELPHI and SQL Server. If these programs fail we need to set our database back to the initial state. Go on the server side and detach the the database, restore the old database from a backup and the start again with our program tests. Long and time consuming procedure.

Can I set a savepoint in the database using Delphi and restore the DB from Delphi if my test failed ?

Upvotes: 1

Views: 370

Answers (1)

marc_s
marc_s

Reputation: 754983

You could easily use SQL Server's Database Snapshots feature for this:

  • create a database snapshot before you start (using CREATE DATABASE snapshot_name.... AS SNAPSHOT OF database_name)

  • run your application

  • if it fails, just restore from that snapshot (using RESTORE DATABASE .... FROM DATABASE_SNAPSHOT = '....')

Upvotes: 2

Related Questions