Hi
Just because no rows are updated does not mean it is an error!! @@ERROR will
still be 0
The number of rows changed will be in @@ROWCOUNT. This could have been
ascertained with a simple test such as:
create table Myupdatetable ( id int, val char(1) )
insert into Myupdatetable ( id, val ) values ( 1, 'A' )
insert into Myupdatetable ( id, val ) values ( 2, 'B' )
insert into Myupdatetable ( id, val ) values ( 3, 'C' )
UPDATE Myupdatetable
SET id = id + 2
WHERE ID % 2 = 1
SELECT @@ERROR, @@ROWCOUNT
UPDATE Myupdatetable
SET id = id + 2
WHERE ID = 0
SELECT @@ERROR, @@ROWCOUNT
John
"M Wells" <pl**********@planetthoughtful.org> wrote in message
news:8j********************************@4ax.com...
Hi All,
Just wondering if you perform an update using a where condition that
actually returns no rows to be updated, does @@Error contain an error
message afterwords?
We want to fire an update ona table against records that may or may
not exists. As a matter of course we test for an @@Error afterwards
and rollback our transaction and exit our stored proc if an error is
returned.
However, we don't want this to happen if there are no records in the
target table that match the where clause of the update statement.
So, if no records are found, does this raise an error?
Many thanks in advance!
Much warmth,
Murrau