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.
| Author |
Topic |
|
vijmeena
Starting Member
10 Posts |
Posted - 2002-12-30 : 01:57:00
|
| I am updating 3-4 tables in a row. Is it possible that the second table does not get updated whereas the 3 and 4 table are updated. Or it is possible that the update of the table is delayed for sometime. |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-12-30 : 02:16:53
|
| update tbl1update tbl2update tbl3update tbl4if you do this then it is possible that any of teh updtes can fail while others succeed (but not delayed).To make sure all or none are updated introduce transaction control and error handling.begin tranupdate tbl1if @@error <> 0beginrollback tranraiserror('failed update',16,-1)returnendupdate tbl2if @@error <> 0beginrollback tranraiserror('failed update',16,-1)returnendupdate tbl3if @@error <> 0beginrollback tranraiserror('failed update',16,-1)returnendupdate tbl4if @@error <> 0beginrollback tranraiserror('failed update',16,-1)returnendcommit tranto check if any rows are affected by the updatedeclare @error int, @rowcount intupdate tbl4select @error = @@error, @rowcount = @@rowcountif @error <> 0 or @rowcount = 0beginrollback tranraiserror('failed update',16,-1)returnend==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|