Tags

, , , , ,


We can use the following command to take the database OFFLINE:

ALTER DATABASE adventureworks SET OFFLINE WITH
ROLLBACK IMMEDIATE
OR
ALTER DATABASE adventureworks SET OFFLINE WITH
ROLLBACK AFTER 30 seconds

I generally prefer this method over sp_dbotion as with ALTER DATABASE we have better control Transaction ROLLBACK.  The default is to wait for all the Currently running Transactions to complete and for the sessions to be terminated. The “ROLLBACK AFTER N Seconds” statement will force currently executing statements to rollback after N seconds. The ROLLBACK IMMEDIATE claus can be used to rollback transactions immediately.

Cheers,

Subhro Saha

Advertisements