Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, you create a database snapshot of the 'clean' state then every hour you revert the 'dirty' database from the clean snapshot. See:</p> <ul> <li><a href="http://msdn.microsoft.com/en-us/library/ms175876.aspx" rel="nofollow noreferrer">How to: Create a Database Snapshot (Transact-SQL)</a></li> <li><a href="http://msdn.microsoft.com/en-us/library/ms189281.aspx" rel="nofollow noreferrer">How to: Revert a Database to a Database Snapshot (Transact-SQL)</a></li> </ul> <p>While other methods also exists (backup/restore, detach/attach and copy files etc) the snapshot based one is probably the fastest because snapshots are diferential based at the file system (they use <a href="http://msdn.microsoft.com/en-us/library/aa365564(VS.85).aspx" rel="nofollow noreferrer">Sparse Files</a>). If your database in 'clean' state is very small (no data in tables) but then it gets much larger during that one hour then it may be simpler or faster to rely on plain backup/restore.</p> <p>Also Database Snapshots are only available in Enterprise Edition of SQL Server, so if your demo uses a lower edition (Standard, Web, Express) you must use a backup/restore or an attach/detach and file copy based solution.</p> <p>Example of a attach/detach file copy based solution:</p> <ol> <li>You have saved the clean db, its files are <code>clean_db.mdf</code> and <code>clean_db_log.ldf</code>.</li> <li>The current dirty db is online, its files are <code>dirty1_db.mdf</code> and <code>dirty1_db_log.ldf</code></li> <li>You copy <code>clean_db.mdf</code> to <code>dirty2_db.mdf</code> and <code>clean_db_log.ldf</code> to <code>dirty2_db_log.ldf</code></li> <li>You detach the database by runing <a href="http://msdn.microsoft.com/en-us/library/ms188031.aspx" rel="nofollow noreferrer"><code>sp_detach_db</code></a> <code>'&lt;dbname&gt;';</code></li> <li>You attach the new files: <a href="http://msdn.microsoft.com/en-us/library/ms179877.aspx" rel="nofollow noreferrer"><code>sp_attach_db</code></a> <code>'&lt;dbname&gt;', 'dirty2_db.mdf', 'dirty2_db_log.ldf';</code></li> <li>You delete the old files <code>dirty1_db.mdf</code> and <code>dirty1_db_log.ldf</code> </li> </ol> <p>This procedures reduces the downtime between detach and attach by copying the clean files <em>before</em> the detach/attach operation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload