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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-09-09 : 08:30:27
|
| evrenjo writes "Hi I have a stored procedure which has INSERT,UPDATE and SELECT statement. I want to make an error handling system which will check error after each sql statement. here, my problem is at which record I get the error. I tried to use @@identity but it didn't work. I couldn't use @@rowcount, either.can you help me about that?thanks a lot." |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-09 : 08:39:55
|
| don't if this is applicable, i used a variable for each statement and assigned a value before executing the next sql statement eg.set @var='statement1'exec sql1set @var='statement2'exec sql2...so if an error is encountered just get the value of @var, usually tedious, just handle the errors and anticipate them, it'll be lot easier |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2004-09-09 : 09:26:48
|
i think what he means is a which record in db did the error happen.but isn't it so that if in an update or insert an error occurs no recors will be inserted or updated?Go with the flow & have fun! Else fight the flow |
 |
|
|
n/a
deleted
35 Posts |
Posted - 2004-09-09 : 13:03:10
|
| correct. the only way to do this is to create a cursor and loop through the cursor inserting/updateing/deleting each record one at a time. then you can add a counter to your cursor and get the row number that it fails at.HTHPaul |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2004-09-09 : 22:41:26
|
| or you can add a trigger to that table and place the error handler there. so let say if you failed to update a table, you can place the row data that failed to be updated or inserted into a another table or file for later viewing? |
 |
|
|
|
|
|