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 |
shmecher
Starting Member
10 Posts |
Posted - 2005-01-24 : 10:57:58
|
Hi. I'm trying to come up with a standardized way of dealing with exceptions in my stored procedures and I have a question:What is the difference between SET @err = @error and SELECT @err = @error? I was told that the SELECT version is not safe, since the select statement might fail, setting @error to an incorrect value. What if the SET statement fails? Isn't it the same thing?ThanksTIBM |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2005-01-24 : 11:21:25
|
>> I was told that the SELECT version is not safe, since the select statement might failnopeconsider if you want to get @@rowcount and @@error. The only way to do this isselect @error = @@error, @rowcount = @@rowcountFor this reason I would always use select for @@error.==========================================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. |
|
|
X002548
Not Just a Number
15586 Posts |
|
shmecher
Starting Member
10 Posts |
Posted - 2005-01-24 : 12:22:05
|
Thanks for the replies.I would still like to know, if I only have to select one variable (only @@error), which statement is better.ThanksTIBM |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2005-01-24 : 13:12:28
|
Well to do proper error handling, you'd need both @@ERROR and @@ROWCOUNT, so there's no choice...Use the search option on the site though....I remeber we had a debate about that...Or look in books onlineBrett8-) |
|
|
|
|
|