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
 SQL Server Development (2000)
 Interview Questions

Author  Topic 

Madman1978
Starting Member

2 Posts

Posted - 2011-03-09 : 19:11:54
Today while applying for a position online, part of the process was to provide answer to a number of questions and one of the questions has me baffled to say the least.

This is the question
quote:
When working within a database, what measures do you implement to make sure you do not accidentally execute a statement improperly (update, insert, delete)?


I have sat here for more then 2 hours attempting to find the answer but no joy as of yet. This question seems ambiguous and open ended. Unless i am missing something.

Any assist or help is helpful

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-09 : 19:24:36
You wrap it into a transaction, check things, then decide commit/rollback.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Madman1978
Starting Member

2 Posts

Posted - 2011-03-09 : 20:08:14
That is what i thought-Just making sure I dont miss something
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2011-03-09 : 21:20:25
If that's what you thought, why'd ya wait 2 hours lol. Just kidding.

One thing I do when making updates in production is to introduce errors on purpose until I'm ready.

For example, I'll key in
UPDATE xxx SET someField...
where xxx doesn't exist. Then I double-check my where clause before changing the xxx to the real table name.

Another thing...before doing an update or delete, run a select with the same conditions so you can review what will be modified before actually changing anything.

Of course, what Tara suggests is the only true fail-safe. You will find from time to time that you can't keep the transaction open for too long without impacting things though. Also DO NOT forget to commit or rollback any transaction.
Go to Top of Page
   

- Advertisement -