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 |
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-10-29 : 10:38:13
|
Hey, it's almost Halloween.I have taken blows from a stored procedure that updates a single user record. I was surprised that no error condition was set when the record was not found.UPDATE AdminsSET Password = @PasswordWHERE AdminID = @AdminIDSET @ERR = @@ERRORIt seems to me that the right way to check that an update actually occured would be to check @@ROWCOUNT, since @ERR is 0, even if a record was not updated.UN-fortunately, it seems that the SET @ERR statement has set @@ROWCOUNT TO 1.How can I retrieve both @@ROWCOUNT AND @@ERROR from the UPDATE statement??Thanks, and Boo! Sam |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2002-10-29 : 10:42:01
|
| No error is set because there isn't an error. Your where statement has excluded all records which is OK.to checkUPDATE Admins SET Password = @Password WHERE AdminID = @AdminID select @ERR = @@ERROR, @rowcount = @@rowcountif @ERR <> 0 or @rowcount = 0beginend==========================================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. |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2002-10-29 : 11:04:46
|
| Thank you Nigel ! Sam |
 |
|
|
|
|
|