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 |
|
PeterG
Posting Yak Master
156 Posts |
Posted - 2003-11-03 : 18:43:28
|
| Q: When writing a stored proc where I do a select before doing a whole bunch of updates and inserts ( to different tables), do I check for error after doing the select? I know I'd have to do error checking after each update and insert. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-11-03 : 19:08:42
|
| The error checking should come after updates, inserts, and deletes. It is not necessary to check for errors on selects. SELECT @var1 = Column1FROM Table1WHERE Column2 = 0UPDATE Table2SET Column1 = @var1WHERE Column2 = 0IF @@ERROR = 0COMMIT TRANELSEROLLBACK TRANTara |
 |
|
|
|
|
|