|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 1:14 AM
Points: 31,433,
Visits: 13,746
|
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 9:02 PM
Points: 21,357,
Visits: 9,538
|
|
Whoops indeed. Aren't you glad you didn't wipe out the post table .
Nice article.
|
|
|
|
|
SSC-Dedicated
           
Group: Administrators
Last Login: Today @ 1:14 AM
Points: 31,433,
Visits: 13,746
|
|
|
|
|
|
SSC-Insane
         
Group: General Forum Members
Last Login: Yesterday @ 9:02 PM
Points: 21,357,
Visits: 9,538
|
|
why not?? it's only 190k rows... and the heart of the site .
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Monday, September 03, 2012 11:06 AM
Points: 659,
Visits: 56
|
|
Sometime ago I created a Query Analyzer template like this:
BEGIN TRAN
/* queries go here */
-- ROLLBACK TRAN -- COMMIT TRAN -- -- SELECT @@TRANCOUNT -- DBCC OPENTRAN
If I make any ad hoc changes, I always use it.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Tuesday, December 04, 2012 10:37 AM
Points: 274,
Visits: 96
|
|
There must have been something in the air yesterday, I did exactly the same thing! Working quickly under pressure on a production system I ran an update but..... didn't highlight the last line of the where clause.....849 lines updated instead of 2...aaargh! Fortunately I preceded the update with a 'begin tran' so I rolled back and tried again! I just reckon this kind of human error is inevitable. Steps to minimise it are (i) implement good change control procedures and adhere to them (what I did, needless to say, contravened all my employer's procedures which made it even worse for me) (ii) get into the habit of preceding all DML statements with 'begin tran' or (iii) set implicit transactions on your session or at a Server level or (iv) use the Enterprise Manager grid display to update individual attributes. Option (ii) - get into the habit of preceding DMLs with 'begin tran' - is the easiest and most hassle free IMHO.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 2:46 AM
Points: 2,750,
Visits: 1,409
|
|
Been there, done that.
To be honest, when I have a single record update I open up the table in Enterprise Manager and edit the record manually. You can't accidentally update umpteen rows accidentally!
For changes to a live environment I tend to script absolutely everything and test on a development database. I run the script from the command prompt. Not perfect but there you go.
I like the idea of the COMMIT / ROLLBACK template.
LinkedIn Profile
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, December 17, 2008 8:34 AM
Points: 108,
Visits: 6
|
|
question? Why don't you have a test platform where changes are made and tested then the changes are uploaded to your production system through reliable change management? It means this sort of thing very hard to happen as the mistake is most often picked up before it makes it into production. The size of your database you could fit a test one on your lap-top. The table you talk about could be termed static data which you script out the data into insert statements and add to your source control where changes could be made in a very controlled manner so rolling back would be very simple and totally auditable. Why don't you use our software to do all of this for you? It is after all free to you (Steve Jones)... regards, Mark Baekdal http://www.dbghost.com
http://www.innovartis.co.uk +44 (0)208 241 1762 Build, Comparison and Synchronization from Source Control = Database change management for SQL Server
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Monday, January 25, 2010 12:24 PM
Points: 79,
Visits: 17
|
|
Mate, I really feel for you, but at least every DBA has done this sometime or the other. I have learn't a lesson from this and I ensure that every thing that I could possibly wrapper in a transaction, I will... This really helps...
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Friday, November 17, 2006 4:44 AM
Points: 1,
Visits: 1
|
|
Great article - think a lot of us have been there. Now if only Ctrl Z would work in Query Analyzer... Andy
|
|
|
|