When your stored procedure is running, what happen if something accidentally occurs? Your update procedure may just copy only some fields of some records.. then stop. Thus, we should manage the transaction for every neccessary stored procedure such as Add, Update, Delete, etc.
This is the example of managing transaction that I found from http://www.4guysfromrolla.com/webtech/080305-1.shtml
[SQL]
BEGIN TRANSACTION
[your process]
IF @@ERROR <> 0
BEGIN
ROLLBACK
RETURN
END
COMMIT
No comments:
Post a Comment