sql server - SQL - update, delete, insert - Whatif scenerio -


i reading article other day showed how run sql update, insert, or deletes whatif type scenario. don't remember parameter talked , can't find article. not sure if dreaming.

anyway, know if there parameter in sql2008 lets try insert, update, or delete without committing it? log or show have updated. remove parameter , run if behaves expect.

i don't know of sql2008 specific feature sql service supports transactions can this:

  1. start transaction ("begin transaction" in tsql)
  2. the rest of insert/update/delete/what-ever code
  3. (optional) select statements , such if needed output result of above actions, if default output step 2 (things "x rows affected") not enough
  4. rollback transaction ("rollback transaction" in tsql)
  5. (optional) repeat testing code show how things without code in step 2 having run

for example:

begin transaction -- make changes delete people name 'x%' delete people name 'd%' exec some_proc_that_does_more_work -- check db state after changes select count(*) people -- undo rollback transaction -- confirm db state without changes select count(*) people 

(you might prefer optional "confirm" step before starting transaction rather after rolling back, i've done way around keeps 2 likely-to-be-identical sections of code easier editing)

if use rather sql2008 specific technique should transferable other rdbs (just update syntax if needed).


Comments

Popular posts from this blog

SAP Web Service from .NET via WCF -

Optimized Line drawing in QT -

datetime - str to time in python -