Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 dealing with missing where clause in update stmt

Author  Topic 

ciaranhurst
Starting Member

1 Post

Posted - 2004-11-06 : 05:41:30
Hi all,
More of a high level question here. Was wondering if any body out there has some trick to prevent silly people like myself forgetting to put in where clause in update statement and bang the entire table gets updated. As I learnt the hard way I now put all the update statements in transactions. However I am lazy and was wondering if people have other ways/tricks/methods/..whatever of dealing with this rather than wrap their queries in transactions

thanks


Ciaran Hurst
Software Developer
Global Betting Exchange Ltd
4th Floor IFSC House
Custom House Quay
Dublin 1, Ireland

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-11-06 : 07:49:01
When I make a booboo like that, I tend to smack my head on the desk repeatedly. If I don't naturally do it out of grief/agony/stupidity, I FORCE myself to do it. Once I regain consciousness, I then add BEGIN TRAN and ROLLBACK TRAN before and after my code for at least the next week so I don't do the same dumbshit thing again. I also welcome the ridicule of my peers in these instances. I make sure I TELL them what a dumbass I am. Their laughter is an additional motivation to add BEGIN TRAN and ROLLBACK TRAN to my code. Lastly, I tell my boss what I did. Assuming I still have a job after that, he/she does a really good job of ensuring that if I ever do a stupid thing like that again, it will be THE LAST TIME I ever do it. And not just at that company either.

In short, no, there's no easy way except self-discipline and punishment. Maybe you should hire a SQL dominatrix to help you with this problem.
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2004-11-06 : 08:02:50
SET IMPLICIT_TRANSACTIONS { ON | OFF }

rockmoose
Go to Top of Page
   

- Advertisement -